Obviously, its seldom to see people using batch files nowadays. Most people dont even know what it is. On, contrary i still use them on my daily tasks to automate things, its like having Perl on a Linux box. but things are changing now, i guess using batch files isn't the trend anymore these days. The same with Linux OS, Windows also comes in handy with some tools used to automate tasks and using batchfiles is one of them. Since we're using Windows XP now, its also wise to do things in GUI mode in contrary with the old style DOS mode edit.
While downloading some pictures from a camera, I found them hard to manually rename its filename to a more meaningful title and not some random "DSC001323.JPG". After rename 10 or 15 files, i got bored, thinking this would take me forerver to rename them all for they are more than a thousand in total. If you can still recall that neat application called Irfan View, my life would have been alot easier.
Well anyway, lets change things we normally do and instead of using batch files we use vb script. A zipped version of the mass renaming script is also available for download.
''''''''''''''''''''''''''''''''''''''''''
' Mass Rename Script by tildemark
' http://www.tildemark.com
'
'
' Usage:
' Place this script on a list of files you wish to rename.
' Run this script by double clicking on the filename.
'
'
' For bugs send it to tildemark@gmail.com
'
''''''''''''''''''''''''''''''''''''''''''
Dim fso, Path, Folder, Counter, Prefix, File, Extension
set fso = CreateObject("Scripting.FileSystemObject")
Path = InputBox("Input the location of the files to be renamed. ('.' means current folder)", "Mass Rename Script", ".")
Prefix = InputBox("Input the filename prefix", "Mass Rename Script")
If Prefix = "\" Then WScript.Quit
Extension = InputBox("Input the file extension to be renamed", "Mass Rename Script")
If Extension = "\" Then WScript.Quit
Counter = InputBox("Input the starting offset", "Mass Rename Script")
Set Folder = fso.GetFolder(Path)
For Each File In folder.Files
If Not ((File.Attributes And 8) = 8) Then
If fso.GetExtensionName(File.Path) = Extension Then
File.Name = Prefix & CStr(Counter) & "." & Extension
End If
End If
Counter = Counter + 1
Next
MsgBox("Done")
Leave a comment