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
- 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.