You are not logged in.
Is there a way to add a 1 of "number" to file names.
Folder
File 1.jpg
File 2.jpg
File 3.jpg
Result Folder
File 1 of 3.jpg
File 2 of 3.jpg
File 3 of 3.jpg
Offline
By using an PascalScript this would be possible
http://www.den4b.com/forum/viewtopic.php?pid=8669#p8669
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
Something like this:
var
SerialNumber: Integer;
FilesCounter: TWideStringArray;
begin
SetLength(FilesCounter, 0);
WideScanDirForFiles(WideExtractFileDir(FilePath), FilesCounter, False, False, False, '*');
SerialNumber := SerialNumber+1;
FileName := WideExtractBaseName(FileName)
+ 'File ' + IntToStr(SerialNumber)
+ ' of ' + IntToStr(Length(FilesCounter))
+ WideExtractFileExt(FileName);
end.
More info about PascalScript:
https://www.den4b.com/wiki/ReNamer:Rules:PascalScript
https://www.den4b.com/wiki/ReNamer:Pasc … Management
- - -
EDIT: script modified to reset file counter if folder name change
var
SerialNumber: Integer;
FilesCounter: TWideStringArray;
CurrentFolder, LastFolder, SerialString: WideString;
begin
//get number of files in current folder into var 'FilesCounter'
SetLength(FilesCounter, 0);
// WideScanDirForFiles(WorkDir, returnVar, Recursive, IncludeHidden, IncludeSystem, Mask);
WideScanDirForFiles(WideExtractFileDir(FilePath), FilesCounter, False, False, False, '*');
//increase file counter by 1:
SerialNumber := SerialNumber+1;
//reset file counter to 1 if folder name change:
CurrentFolder := WideExtractFileDir(FilePath);
if not WideSameText(CurrentFolder, LastFolder) then SerialNumber := 1;
//Pad SerialNumber to wanted length (change "<1" to "<3" to get SerialString with at least three digits):
SerialString := IntToStr(SerialNumber);
While (Length(SerialString) < 1) Do
SerialString := '0'+ SerialString;
//compose new filename:
FileName := WideExtractBaseName(FileName)
+ ' - File ' + SerialString
+ ' of ' + IntToStr(Length(FilesCounter))
+ WideExtractFileExt(FileName);
LastFolder := CurrentFolder;
end.
Last edited by Stefan (2020-06-15 16:57)
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
The file counter script produces 0.
//get number of files in current folder into var 'FilesCounter'
SetLength(FilesCounter, 0);
WideScanDirForFiles(FilePath, FilesCounter, False, False, False, '*');
Offline
The file counter script produces 0.
Ah, yes sorry, now already adjusted above.
"WideScanDirForFiles(FilePath" changed to "WideScanDirForFiles(WideExtractFileDir(FilePath)"
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
THANK YOU! That is very close. Now I see that there are more than just .jpg files in the folder that are being counted. Is there a way to modify the script to only count .jpg files?
Found the solution in the Mask portion of the WideScanDirForFiles(WorkDir, returnVar, Recursive, IncludeHidden, IncludeSystem, Mask)
Last edited by dannician (2020-06-15 19:50)
Offline