#11 2013-01-30 15:09

alcestneige
Member
Registered: 2013-01-19
Posts: 28

Re: Intelligent counting and renaming of files - Pascal script

Hi

It runs = there was no error reported by ReNamer after I hit the green 'Rename' button, just the result message pop up (XY files were renamed successfully)
Tested = I run ReNamer on folder posted below with only one JPG file and also with more JPG files

Folder structure is very simple, copied from the CSV file:
One file/1st test:
C:\Users\JM\Desktop\Movies\Thor
C:\Users\JM\Desktop\Movies\Thor\Image.jpg

-I added only one file to the Thor folder
-After you hit the green button the name of the 'Image.jpg' file should be 'Poster.jpg' and not 'Poster 1.jpg' -> not working

More files/2nd test:
C:\Users\JM\Desktop\Movies\Thor
C:\Users\JM\Desktop\Movies\Thor\Image.jpg
C:\Users\JM\Desktop\Movies\Thor\Imagee.jpg

-I added two files to the Thor folder
-After you hit the green button the name of the 'Image.jpg' and 'Imagee.jpg' file should be 'Poster 1.jpg' and 'Poster 2.jpg' -> this works

Last edited by alcestneige (2013-01-30 15:11)

Offline

#12 2013-01-30 15:44

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

Re: Intelligent counting and renaming of files - Pascal script

That's not your real data.
There are for example no *.png and no *.gif or other files as you have mentioned above.
Jan > but I need to focus just on image files like JPG, GIF and PNG, because in the folder
Jan > can be as image files so other files like AVI, SRT and so on, those files have to stay untouched.


Second, i miss to ask how you add the files to ReNamer.
Do you add the whole "Movies" folder, or just all sub folders like "Thor" ?
Or do you add folder by folder?


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

#13 2013-01-30 15:57

alcestneige
Member
Registered: 2013-01-19
Posts: 28

Re: Intelligent counting and renaming of files - Pascal script

Yes it's not the real data, but right now in the real data I do not have GIF or PNG files anyway, the main file is the JPG file, but in the future it does not have to be like that, therefore I'm counting also with GIF and PNG files. Is that a problem?

I add the whole Movies folder to ReNamer. Actually I click with the right mouse on Movies folder and choose Add to ReNamer.

Offline

#14 2013-01-30 16:03

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

Re: Intelligent counting and renaming of files - Pascal script

OK, i did an test


* I have this files

Movies\Single\Image.jpg
Movies\Single2\Image.jpg
Movies\Multi\Image.jpg
Movies\Multi\Imagee.jpg
Movies\Multi\ImageB.jpg
Movies\Multi\ImageC.jpg
Movies\Multi2\Image.jpg
Movies\Multi2\Imagee.jpg
Movies\Multi2\ImageB.jpg
Movies\Multi2\ImageC.jpg

* I have added all sub folder of "Movies" to ReNamer, Filter "Add Files Within Folders"

* i have added this rules:
1) Replace: Replace using wildcards "*" with "Poster " (skip extension)
2) Serialize: Serialize Incremental from 1 step 1 repeat 1 and pad to length 3 as suffix (before extension)
3) PascalScript: var Files:TStringsArray; begin //Scan Folder of this current files for amount of files: WideScanDirForFiles( WideExtractFilePath(FilePath), Files, false, false, false, '*.jpg'); //If only one file found in folder of current file: if Length(Files) = 1 then begin //Rename that file: FileName := 'Poster' + WideExtractFileExt(FileName); end; //clear array for next file: setlength(Files,0) end.




* i have see that this doesn't work
" '*.jpg;*.gif;*.png' "
and therefore changed to
" '*.jpg' "

BUT we could also use " '*' " for all file types.
And use ReNamer Filter settings too add only images files to this process.

Jan > but I need to focus just on image files like JPG, GIF and PNG, because in the folder
Jan > can be as image files so other files like AVI, SRT and so on, those files have to stay untouched.




* i have renamed and got

F:\Movies\Multi\Poster 002.jpg
F:\Movies\Multi\Poster 003.jpg
F:\Movies\Multi\Poster 004.jpg
F:\Movies\Multi\Poster 005.jpg
F:\Movies\Multi2\Poster 006.jpg
F:\Movies\Multi2\Poster 007.jpg
F:\Movies\Multi2\Poster 008.jpg
F:\Movies\Multi2\Poster 009.jpg
F:\Movies\Single\Poster.jpg
F:\Movies\Single2\Poster.jpg

There is a problem anyway, because if there is a single-file folder in between
the serial numbers are out of order, because we add serial numbers at first to ALL files
and then rename single files back afterwards and so numbers in between gets missed.
As seen above, we get 002 to 009. So "reset index if folder changes" option works better.





1)
2) Serialize: Serialize Incremental from 1 step 1 repeat 1 (reset index if folder changes) and pad to length 3 as suffix (before extension)
3)

F:\Movies\Multi\Poster 001.jpg
F:\Movies\Multi\Poster 002.jpg
F:\Movies\Multi\Poster 003.jpg
F:\Movies\Multi\Poster 004.jpg
F:\Movies\Multi2\Poster 001.jpg
F:\Movies\Multi2\Poster 002.jpg
F:\Movies\Multi2\Poster 003.jpg
F:\Movies\Multi2\Poster 004.jpg
F:\Movies\Single\Poster.PNG
F:\Movies\Single2\Poster.jpg

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

#15 2013-01-30 16:21

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

Re: Intelligent counting and renaming of files - Pascal script

alcestneige wrote:

Yes it's not the real data, but right now in the real data I do not have GIF or PNG files anyway, the main file is the JPG file, but in the future it does not have to be like that, therefore I'm counting also with GIF and PNG files. Is that a problem?

Yes it is a problem because you wanted that ReNamer works as you like. Therefor we have to test it out. Therefore we need your real structure.
Of course i could do this myself and create that myself, but why should i?


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

#16 2013-01-30 16:40

alcestneige
Member
Registered: 2013-01-19
Posts: 28

Re: Intelligent counting and renaming of files - Pascal script

So the only problem was in this part right?

* i have see that this doesn't work
" '*.jpg;*.gif;*.png' "
and therefore changed to
" '*.jpg' "

It works only with one extension, hell I did not tried that sad

But in that case I could add two more rules with the same script just the extension would be in one case GIF and ind second PNG.


And

Of course i could do this myself and create that myself, but why should i?

That's true, I did not want to be rude, sorry about that, I was just thinking a bit forward smile

I will test that for a while now and I will let you know.

Thank you very much for your time Stefan, you are the man!

Offline

#17 2013-01-30 18:01

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

Re: Intelligent counting and renaming of files - Pascal script

Ok enough played.
I took some time and test it myself wink
I think now i got it what you want and coded all steps in PascalScript

FROM ==> TO

F:\New\Movies\Multi\another image.jpg	Poster 001.jpg
F:\New\Movies\Multi\Image.jpg	Poster 002.jpg
F:\New\Movies\Multi\ImageB.jpg	Poster 003.jpg
F:\New\Movies\Multi\what is this.jpg	Poster 004.jpg

F:\New\Movies\Multi2\ImageB.jpg	Poster 001.jpg
F:\New\Movies\Multi2\ImageC.avi	ImageC.avi
F:\New\Movies\Multi2\ImageC.txt	ImageC.txt
F:\New\Movies\Multi2\Imagee.png	Poster 002.png
F:\New\Movies\Multi2\Some name.gif	Poster 003.gif
F:\New\Movies\Multi2\temp file.tmp	temp file.tmp

F:\New\Movies\Single\Image.jpg	Poster.jpg

F:\New\Movies\Single2\I am Single 2.jpg	Poster.jpg

F:\New\Movies\Single3\Image No3.avi	Image No3.avi
F:\New\Movies\Single3\Image Test 3.txt	Image Test 3.txt

with an single PascalScript rule:

* work only on specific extension 'JPG;PNG;GIF'
* replace whole old name
* add new name 'Poster'
* if more then one "specific extension" in an folder > add serialize number after new name 'Poster'

var
 Files:TStringsArray;
 i, Pad:integer;
 ExtArray, ExtOrig, ExtTmp, OldParent, serial, NewName:String;
 
begin
  // User Settings:
  Pad      := 3; //pad serial number to three digits
  ExtArray := 'JPG;PNG;GIF'; //rename only this file types
  NewName  := 'Poster';
  //-----------------------------------
  ExtOrig  := WideExtractFileExt(FileName);
  ExtTmp   := WideUpperCase(ExtOrig);
  ExtTmp   := WideReplaceStr(ExtTmp,'.','');

  //reset serial number on folder change:
  if(WideExtractFilePath(FilePath) <> OldParent) then
     i :=1; 
  OldParent := WideExtractFilePath(FilePath);

  //Do only if current extension is in Ext Array:
  if( WideTextPos(ExtTmp,ExtArray) > 0 ) then
  begin
     WideScanDirForFiles( WideExtractFilePath(FilePath),
             Files, false, false, false, '*');
             
     if Length(Files) = 1  then
     begin
         FileName := NewName + ExtOrig;
     end else
     begin
         serial := IntToStr(i);
         while(length(serial)<Pad) do serial := '0'+serial; //padding
         FileName := NewName + ' ' + serial + ExtOrig
     end;
     setlength(Files,0);//clear array for next file
     i := i+1; //incr serial number
  end;
end.

I hope i got it now?
Only that jpg + png + gif are serialized together: 001.jpg, 002.png, 003.gif,...


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

#18 2013-01-31 19:31

alcestneige
Member
Registered: 2013-01-19
Posts: 28

Re: Intelligent counting and renaming of files - Pascal script

This is EXACTLY Stefan what I was looking for!
Unbelievable what you did!

Now I'm completely done with all the requests and a monstrum tool came to life big_smile
And firstly I thought that ReNamer is only for one thing, well, this is a dangerous and complex tool, you just have to know how to handle it and you really can do that!

Again, many thanks for all the great work, patience, time and help.
You are the man!

Be safe!
Jan

Offline

Board footer

Powered by FluxBB