You are not logged in.
Pages: 1
Hi guys
I am looking for a way to increment a number - but only when the folder changes.
The reason: 8 folders with a tv series.
Each folder represents a different season and the tricky bit is that the number of shows in each season/folder varies.
Basically I need to add "S0XXEXX" to all the files.
In folder 1 the first show would be "S01E01" and the second would be "S01E02".
In folder 2 the first show would be "S02E01" and the second would be "S02E02" etc.
Any easy way of doing this or do I have to do it on a folder by folder basis (not optimal)?
Thanks in advance
/Esben
Last edited by EsbenRasmussen (2011-09-19 19:33)
Offline
Hi Esben, welcome.
I am looking for a way to increment a number - but only when the folder changes.
...
Basically I need to add "S0XXEXX" to all the files.
SZZEXX
ZZ same for all files but increment for each folder.
XX increment for each file, but reset for each folder
Example:
S ZZ E XX
PATH NAME NewName
\Tests\SubFolders\1One\ Eins.jpg Eins S 01 E 01.jpg
\Tests\SubFolders\1One\ Eins.mp3 Eins S 01 E 02.mp3
\Tests\SubFolders\1One\ Eins.txt Eins S 01 E 03.txt
\Tests\SubFolders\2Two\ ZWEI.jpg ZWEI S 02 E 01.jpg
\Tests\SubFolders\2Two\ ZWEI.mp3 ZWEI S 02 E 02.mp3
\Tests\SubFolders\2Two\ ZWEI.txt ZWEI S 02 E 03.txt
\Tests\SubFolders\3Three\ drEI.jpg drEI S 03 E 01.jpg
\Tests\SubFolders\3Three\ drEI.mp3 drEI S 03 E 02.mp3
\Tests\SubFolders\3Three\ drEI.txt drEI S 03 E 03.txt
For files (XX):
If you use one of the latest betas or the last release 5.60
you can use the "Serialize" rule and check the "Reset if folder change" option.
For folders (ZZ):
We have to use an PascalScript, i think,
since we want to have the same ZZ number for all files within same folder
but increase ZZ for each new folder.
So i would use this four rules:
1) Insert: Insert "S" as Suffix (skip extension)
2) PascalScript: {add the same counter for all files but increase counter for each new folder} ...
3) Insert: Insert "E" as Suffix (skip extension)
4) Serialize: Serialize Incremental from 1 step 1 (reset index if folder changes) and pad to length 2 as suffix (before extension)
The "ZZ" PascalScript script for rule #2:
(for an how-to use this, see our wiki at >>> http://www.den4b.com/wiki/ReNamer:Rules:PascalScript)
{Comment: add the same counter for all files but increase counter for each new folder}
var
ParentFolder, LastPF, countStr, PrevRules: widestring;
cnt: integer;
begin
//get the current parent-folder name:
ParentFolder := CalculateMetaTag(FilePath, ':File_FolderName:');
//initialize the counter var:
if cnt < 0 then cnt := 1;
//if the parentfolder is an other then the last PF, then increase the counter:
//if ParentFolder = LastPF then cnt := cnt;
if ParentFolder <> LastPF then cnt := cnt + 1;
//we need to have an string for the following steps:
countStr := IntToStr(cnt);
//pad digit with zeros to wanted length:
while length(countStr) < 2 Do countStr := '0' + countStr;
//compose the new FileName:
//calculate the previous rules:
PrevRules := WideExpandFileName(FileName);
//new name:
FileName := WideExtractBaseName(PrevRules)
+ countStr + WideExtractFileExt(PrevRules);
//set the LastParentFolder-var to the current parent folder name:
LastPF := ParentFolder;
end.
I hope this works and helps. If yes, please help Denis too (see my sig)
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
Where's the feedback? Did it work?
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
Hi Stefan
I haven't had time to test it yet - had a very busy week.
Will test it later today and let you know.
Thank you very much for your help and patience.
Offline
It works!
Thank you very much for the assistence!
/Esben
Offline
BTW there's an error somewhere on the donations page - there's not a single piece of HTML being returned.
Offline
Thanks for the feedback! Great you solved your challenge.
BTW there's an error somewhere on the donations page - there's not a single piece of HTML being returned.
Upps, sorry, that was me, an old URL. I didn't have updated my sig till now...
...so, done. Link works now again. Thanks for your support.
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
Pages: 1