#1 2020-05-08 21:48

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Serialize files excluding when only one in a folder

Hello,
is there a way that re-namer only counts files in a folder when there is only more than 1 file?
Thanks!

Offline

#2 2020-05-09 09:01

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Serialize files excluding when only one in a folder

Hi and welcome, Karleesi.

Me think on default this is not possible, maybe by using an PascalScript.

Please tell us what you exactly like to do.
As far as I understood, you want to serialize your JPGs from 1 to x, individual for each folder?

And show us your current used rules (see context menu in Rules window > Export to Clipboard)

Perhaps somebody get an idea.

Maybe the key is to combine your tools?
First use TC to search for folders with more than one file, then select the resulting folders and drag&drop to ReNamer...
Not sure right now how to do that, though.




 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2020-05-09 10:24

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Serialize files excluding when only one in a folder

Thanks for your reply. It's actually pretty basic:
I just want the files to be named like their folder they're in. Plus number them. But when there's only 1 file in the folder the counting doesn't make sense. It says (logically) file1.jpg then, for example. But no number needed because it's just one file in the folder.
I managed to do that, it looks like this.
FolderA:
File1, File2, File3
Files become: FolderA1, FolderA2, FolderA3
FolderB:
File1
file becomes: FolderB1
so the "1" is not needed because it's just one file anyway.

I've saved 2 settings now, 1 with numbering and 1 without numbering. Which means before renaming or using the software I have to sort all folders by 2 categories, "1 file folders" and "2 or more file folders". I'd like to skip that step.
I hope you understand me now.

Thanks for everything

The 2nd screenshot is for single files, the 1st for multiple files.

61d818-1589016139.jpg

fbc372-1589016207.jpg

Offline

#4 2020-05-10 10:18

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Serialize files excluding when only one in a folder

You could use the Pascal Script rule as the last rule to strip the serialization index from files which are sitting alone in their directory.

Is your serialization index appears at the end of the filename, just before the extension?

P.S. I do not understand the language in your screenshots. You can temporarily switch language to English and then export your rules to clipboard using the right-click context menu option.

Offline

#5 2020-05-10 10:58

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Serialize files excluding when only one in a folder

Thank you. Can you tell me how to do that with the Pascal script?

"Is your serialization index appears at the end of the filename, just before the extension?"

Exactly. Like "File1.jpg"

Last edited by Karleesi (2020-05-10 11:06)

Offline

#6 2020-05-10 11:04

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Serialize files excluding when only one in a folder

1st pic is single file, 2nd is multi file folders.

mini_single.jpgmini_mult.jpg

Last edited by Karleesi (2020-05-10 11:11)

Offline

#7 2020-05-10 12:09

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Serialize files excluding when only one in a folder

> Serialize only if more than one file in a folder

This is the script I need, perfect! But I have no idea how to do that! smile

Last edited by den4b (2020-05-10 18:32)

Offline

#8 2020-05-10 18:39

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Serialize files excluding when only one in a folder

Yes, that script should do the trick for you. By default, it will strip all trailing digits and underscores from JPG files, but only if it is the only file in a directory.

You can adjust the FileMask and StripChars constants at the top of the script to suit your needs. Apart from that, you just need to add a Pascal Script rule with this script as the last rule in your list of rules.

const
  FileMask = '*.jpg';
  StripChars = '_0123456789';
var
  Files: TWideStringArray;
begin
  SetLength(Files, 0);
  WideScanDirForFiles(WideExtractFileDir(FilePath),
    Files, False, False, False, FileMask);
  if Length(Files) = 1 then
  begin
    FileName := WideExtractFilePath(FileName) +
      WideTrimCharsRight(WideExtractBaseName(FileName), StripChars) +
      WideExtractFileExt(FileName);
  end;
end.

Offline

#9 2020-05-11 05:54

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Serialize files excluding when only one in a folder

Ok, thank you. Is there a way I can use that rule for every extension at the same time and not just .jpg? Let's say I have files with .jpg, .jpeg, .png, and so on. Thanks again.

Offline

#10 2020-05-11 08:19

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Serialize files excluding when only one in a folder

Karleesi wrote:

Is there a way I can use that rule for every extension at the same time and not just .jpg? Let's say I have files with .jpg, .jpeg, .png, and so on.

Yes, just change the FileMask constant to "*" or "*.*", like follows:

const
  FileMask = '*';

Offline

Board footer

Powered by FluxBB