Naming files issue...
Published on August 20, 2007 By RPGFX In Personal Computing
Hello wonderful folks of WC! Was just wondering if anyone out there knew if there was a way to rename multiple files all at once. I have a folder full of pictures, all with various different names, and I'll like to rename them 0001 through 0500 (or however many there are) without individually renaming hundreds of files. I know if you highlight them all and right click and rename, I can give them all the SAME name with (2) after it, but that's not what I'm going for here. Any clues?
Comments
on Aug 20, 2007
Directly from Windows there is no way. Either use a script or search for File Renaming freeware.
on Aug 20, 2007
you dont care about the existing names? you just want everything in the folder to be named 0001 - 0500.jpg?

I might be able to make a simple widget to drop a folder onto and have all the files renamed, but i have not looked into the "rename" in the fso object. It really doesnt sound hard.

1. read the folder
2. get a list of all the file names - put them in an array
3. start a counter at 0001
4. rename the files and update the counter for each file.

Let me know if your interested.
on Aug 20, 2007
I used a freebie called A.F.5 Renamer before I got Adobe Lightroom. Just the thing for renaming photos. You can get it HERE
on Aug 20, 2007
This is what I use.  It has a variety of other features aside from batch renaming as well.

http://www.faststone.org/FSResizerDetail.htm

 
on Aug 20, 2007
1. read the folder
2. get a list of all the file names - put them in an array
3. start a counter at 0001
4. rename the files and update the counter for each file.


That is a widget that could be of some use. I am wondering if it could also name file extensions at the same time. Example.. From .PSD to .PNG, etc.   
on Aug 20, 2007

well i was playing..

1. got it to read a "set" folder
2. got it to read the list of files
3. added a counter to make the new file names
4. have it check for ".jpg" files (for this example)
5. renames the old file to 0001.jpg up to 9999.jpg

Works pretty good, crappy interface but it works. (right now its just a text listing).

The code was pretty simple: (again i have HARD-CODED the folder for testing)
All of this is in a simple TEXT object.

Code: vbscript
  1. Sub Object_OnScriptEnter
  2. path = "d:\renameme"
  3. object.text = "reading.." & vbnewline
  4. Set filesys = CreateObject("Scripting.FileSystemObject")
  5. Set TargetFolder = filesys.GetFolder(Path)
  6. Set FolderFiles = TargetFolder.Files
  7. cnt = 0
  8. For Each OldFileName In FolderFiles
  9. cnt = cnt +1
  10. If UCase(right(OldFileName,3)) = "JPG" Then
  11. If cnt < 10 Then NewFileName = "000" & cnt & ".jpg"
  12. If cnt => 10 And cnt < 100 Then NewFileName = "00" & cnt& ".jpg"
  13. If cnt => 100 And cnt < 1000 Then NewFileName = "0" & cnt& ".jpg"
  14. NewFileName = Path & "\" & NewFileName
  15. object.text = object.text & OldFileName & " to " & newfilename
  16. filesys.MoveFile OldFileName, newfilename
  17. object.text = object.text & " -- RENAMED " & vbnewline
  18. End If
  19. Next
  20. End Sub


It would make more sense to move the new files to a "renamed" folder or something.
Im sure it could be tweeked to do a lot of things.

There are a lot of "renamers" out there (did a search) so i dont know how much time to spend on this. But the code is here.

 

// Edited by andrew_; Pasted the code from the correction reply to fix the code block.

on Sep 03, 2007
Let me know if your interested.


certainly something I would love to have! And I'm sure others would love it too... thanks for offering your services, would love to see it produced!
on Sep 03, 2007
I will have to see what i can do. IT seems to work as it is (hardcoded) but its kind of a strange program, not a lot of people will want to globally rename all their files.
on Sep 03, 2007
Irfanview has a batch process/rename feature which I've used in the past...it's easy and works well for what I need.

...but that would be cool if RomanDA could custom make one.   
on Sep 03, 2007
lol wow... You guys call yourselves Guru's... Windows will rename any number of files that your computer can handle... Just select all in the directory, and just friggin hit F2.. Name it something like: 1.jpg... Then all the other files will be: 1(1).jpg, 1(2).jpg... ext.
on Sep 03, 2007
I surprised Roman didn't post a widget.
on Sep 04, 2007
Roman has been working.. thats why.. And im kind of leary of posting "rename" or "move" widgets as there is a LOT of potential for losing files..

The File Transporter was to have a copy/move built into it, but i had it nuke a file of mine when it was to "move" it and something wasn't correct, so.. i just got rid of those functions.

The code above works, and could be made into a widget without a ton of work. but as its been pointed out here, there are other ways to do this, and im not a huge fan of re-creating the wheel. I like to do things not already done.
on Sep 05, 2007
Yeah. It's same for me. That's why I rarely make skins and stuff. XXCalc and XXLog was unique in its era.
on Sep 05, 2007
lol wow... You guys call yourselves Guru's... Windows will rename any number of files that your computer can handle... Just select all in the directory, and just friggin hit F2.. Name it something like: 1.jpg... Then all the other files will be: 1(1).jpg, 1(2).jpg... ext.


maybe you should read my original post again before blasting all these nice people trying to help me...

I know if you highlight them all and right click and rename, I can give them all the SAME name with (2) after it, but that's not what I'm going for here.


on Sep 05, 2007
I use RN 1-4a rename (FREE)

Read all about it HERE

Robert