You are not logged in.
Hi all!
I'm wondering if ReNamer is capable to handle this task.
If you have a folder with many files in it, let's say 'JPG' files in a folder called 'Photo'.
Photo
asd.jpg
easd.jpg
ewr.jpg
kxvo.jpg
And you want to rename those files with proper name like 'Image', you use a function 'Serialize' in ReNamer to get proper names like 'Image 01.jpg, Image 02.jpg ...03.jpg and so on'.
So you get:
Photo
Image 01.jpg
Image 02.jpg
Image 03.jpg
And here comes the tricky part.
If you have more 'Photo' folders with different number of files in it, like above mentioned 2,3 or more files in a folder, but you also can have just a one file in the folder, so you certainly don't want to name a single file to 'Image 01.jpg', if there is and also there will be no more files in the folder. You want to name it just 'Image.jpg' right?
To get a better picture of my problem:
!WRONG example!
Photo1
Image 01.jpg
Photo2
Image 01.jpg
Image 02.jpg
Image 03.jpg
!CORRECT example!
Photo1
Image.jpg
Photo2
Image 01.jpg
Image 02.jpg
Image 03.jpg
So is there a way to proper rename the single file without numbers (counting), when there is and will be only one file?
Is there a way to check backwards how many files are in the folder and if there is just one 'Image 01.jpg' to rename it back to 'Image.jpg?
Thank you for any reaction on this topic!
Jan
Offline
you get ideas ;-)
But you are right of course.
I think an solution would be an additional trailing PascalScript with something like
Files := WideScanDirForFiles(x,x,x);
if (Files=1) then
LEN := WideLength(FileName);
FileName := WideDelete(FileName, LEN -3, 3);
See http://www.den4b.com/wiki/ReNamer:Pasca … :Functions
If i find time i will aid you by creating such an script.
Tip: you can use the Analyze windows (Shift+A) to test your script.
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
Yeah I know Stefan I just figured out that there is a ReNamer in this world
And it can solve my problems=save lots of time.....
Thanks again for your reply Stefan, but unfortunately I'm too tired to keep an eye on this right away and I guess you are tired to answer my dumb questions/problems every time as well, so I should come down a bit
Bye and see ya!
Jan
Offline
Stefan, the prev. topic is solved now, would you mind to focus on this one please?
Only if you have time of course!
Thanks!
Jan
Offline
Hi Jan,
I think an solution would be an additional trailing PascalScript with something like
Files := WideScanDirForFiles(x,x,x);
if (Files=1) then
LEN := WideLength(FileName);FileName := WideDelete(FileName, LEN -3, 3);
See http://www.den4b.com/wiki/ReNamer:Pasca … :Functions
If i find time i will aid you by creating such an script.
Tip: you can use the Analyze windows (Shift+A) to test your script.
I have tried it this way:
I have a few sub folders and drag&drop that folders to ReNamer.
Filter settings are: "[X] Add Files Within Folders"
A few folder has more then one file, others has one file only.
By using the script below the single files gets renamed to "Image" with original extension.
Do you think that is what you need?
I guess it depends how you work. How you add files or folders.
All sub folders at onces? Or do you rename folder for folder?
For my simple tests it works.
Test it with a few files/folders only. And have a recent backup.
var
Files:TStringsArray;
begin
//Scan Folder of this current files for amount of files:
WideScanDirForFiles( WideExtractFilePath(FilePath),
Files, false, false, false, '*');
//If only one file found in folder of current file:
if length(Files) = 1 then
begin
showmessage( WideExtractFilePath(FilePath) );
//Rename that file:
FileName := 'Image' + WideExtractFileExt(FileName);
end;
//clear array for next file:
setlength(Files,0)
end.
HTH?
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
Yes it could be the script, but I need to focus just on image files like JPG, GIF and PNG, because in the folder can be as image files so other files like AVI, SRT and so on, those files have to stay untouched.
And what I have is one folder called movie with many subfolders (separate movie titles with movie files and images) and in those folders are again subfolders called Subtitles, but in those folders are only subtitle files.
So to get a picture (bold=folder):
Movie
Thor
Thor.avi
Poster01.jpg
Subtitles
Thor.srt
And the point is, if there is just one image file (JPG, GIF, PNG) it should be named Poster, but if there are many image files, then they should be named Poster 1, Poster 2, Poster 3 and so on
Thanks!
Jan
Last edited by alcestneige (2013-01-29 21:47)
Offline
Jan > it should be named Poster
Why now 'Poster'? I think 'Image'? Why do we always the work twice?
Anyway,change
FileName := 'Image' +
to
FileName := 'Poster' +
Jan > but I need to focus just on image files like JPG, GIF and PNG
try if it works to change
Files, false, false, false, '*')
to the usual
Files, false, false, false, '*.jpg;*.gif;*.png')
See http://www.den4b.com/wiki/ReNamer:Pasca … _Utilities
Jan > but if there are many image files, then they should be named Poster 1, Poster 2, Poster 3 and so on
The renaming of "Poster 1, Poster 2, Poster 3" you do yourself with Serialize Rule.
Then use the PascalScript to re-rename single files back from "Poster 1" to "Poster"
As far as i understood what you want i think that should do the trick. No?
.
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
I'm sorry, Image or Poster is same for me, I wasn't focused on that as I wrote the comment.
About the Serialize Rule, I know how it works, I did that also before (you guided me on that )
Thanks for the hint, I will try that soon as possible and I will let you know.
Thanks again Stefan, have a nice night!
Jan
Offline
So, the final code should look like this right?
var
Files:TStringsArray;
begin
//Scan Folder of this current files for amount of files:
WideScanDirForFiles( WideExtractFilePath(FilePath),
Files, false, false, false, '*.jpg;*.gif;*.png');
//If only one file found in folder of current file:
if length(Files) = 1 then
begin
showmessage( WideExtractFilePath(FilePath) );
//Rename that file:
FileName := 'Poster' + WideExtractFileExt(FileName);
end;
//clear array for next file:
setlength(Files,0)
end.
Unfortunately it does not work, it runs without any problems or error, but also without changes.
I'm attaching the whole ReNamer template, so you can look on that.
Comments to the template:
1) first line - it removes the whole name of the file except of his extension
2) second line - it names the file to 'Poster', no change on extension
3) third line - serialize, it adds numbers after the name of the file (it counts the files 1,2,3...Poster 1, Poster 2, Poster 3... and so on), no change on extension
4) fourth line - here comes the script which should identify how many (JPG, GIF, PNG) files are in the folder, if there is just one, it renames it back to 'Poster', if there are more files, then without changes
It was tested as with two or more JPG files, so with only one JPG file.
And yes, now we are on the same line I guess
Please let me know what do you think.
Thank you!
Jan
Offline
Hi,
what means "it runs" or "Tested" ?
Did you have done an Preview only or did you actually executed the real Renaming?
Can you post your folder structure for recreation?
How-to:
* add all files (or only a few relevant so we get an idea) to ReNamer
* be sure NOT to have anything in the NewName column (disable Preview) We need NAME column only.
* Export the list with "Export > Export file paths and undo paths" as CSV
* post that list so we can recreate it on our disk to see what you see.
.
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