Calling all gurus!
Naming files issue...
Monday, August 20, 2007 by RPGFX | Discussion: Personal Computing
Reply #2 Monday, August 20, 2007 4:56 PM
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.
Reply #4 Monday, August 20, 2007 5:38 PM
http://www.faststone.org/FSResizerDetail.htm
Reply #5 Monday, August 20, 2007 5:45 PM
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.
Reply #6 Monday, August 20, 2007 6:06 PM
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.
- Sub Object_OnScriptEnter
- path = "d:\renameme"
- object.text = "reading.." & vbnewline
- Set filesys = CreateObject("Scripting.FileSystemObject")
- Set TargetFolder = filesys.GetFolder(Path)
- Set FolderFiles = TargetFolder.Files
- cnt = 0
- For Each OldFileName In FolderFiles
- cnt = cnt +1
- If UCase(right(OldFileName,3)) = "JPG" Then
- If cnt < 10 Then NewFileName = "000" & cnt & ".jpg"
- If cnt => 10 And cnt < 100 Then NewFileName = "00" & cnt& ".jpg"
- If cnt => 100 And cnt < 1000 Then NewFileName = "0" & cnt& ".jpg"
- NewFileName = Path & "\" & NewFileName
- object.text = object.text & OldFileName & " to " & newfilename
- filesys.MoveFile OldFileName, newfilename
- object.text = object.text & " -- RENAMED " & vbnewline
- End If
- Next
- 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.
Reply #7 Monday, September 3, 2007 11:01 AM
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!
Reply #8 Monday, September 3, 2007 11:39 AM
Reply #9 Monday, September 3, 2007 5:30 PM
...but that would be cool if RomanDA could custom make one.
Reply #10 Monday, September 3, 2007 7:14 PM
Reply #12 Tuesday, September 4, 2007 7:44 AM
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.
Reply #13 Wednesday, September 5, 2007 10:01 AM
Reply #14 Wednesday, September 5, 2007 12:22 PM
maybe you should read my original post again before blasting all these nice people trying to help me...
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Monday, August 20, 2007 4:20 PM