You are not logged in.
Pages: 1
Is there a way to add a number to the end of each file only after more than one file in the folder is present?
Offline
It should be possible with the Pascal Script rule.
Can you provide a complete example of the input and desired output file paths?
Offline
What I mean to say is that if there is only one picture in a folder it does not get _# attached to the end but if there are two then they both get a number. If this interferes with the final sort order than i will accept single images having numbers but if not that would be pretty cool.
Original.....
Folder1
Image.jpg
Folder2
Image.jpg
Image.jpg
Folder3
Image.jpg
Folder4
Image.jpg
Image.jpg
Image.jpg
Image.jpg
Result.......
New Folder
Folder1_Image.jpg
Folder2_Image_1.jpg
Folder2_Image_2.jpg
Folder3_Image.jpg
Folder4_Image_1.jpg
Folder4_Image_2.jpg
Folder4_Image_3.jpg
Folder4_Image_4.jpg
Hope that helps.
Offline
The whole thing can be achieved with a Pascal Script rule, but we'll try to keep as much as possible to the standard rules.
Serializing files according to their folder can be accomplished with the standard rules. Use the Serialize rule with the "reset index if folder changes" option. It will leave you with one last task - stripping out number suffixes from files which came from 1-file folders - that will have to be done by a Pascal Script rule.
Note that the files are sorted by the Path column.
And here is that magic script:
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
Pages: 1