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
' https://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
'
''''''''''''''''''''''''''''''''''''''''''
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")
You can use the editor commands and system command in biterscripting ( http://www.biterscripting.com for free download) very effectively to rename, copy, delete, etc files in Windows. I just posted a script in reply to a similar topic on another web site at http://en.kioskea.net/forum/affich-20320-dos-script-to-rename-files . Do take a look.
Their editor commands are powerful and a script, once developed, will work in all windows versions.
Hope this helps.
Sen
Hi, good to see this script. I have been trying a similar approach, but 'm stuck in being able to rename in a different way.
i have a bunch of files with this format
01 1a.txt
02 1b.txt
03 1c.txt
01 2a.txt
02 2b.txt
03 2c.txt
etc
I would like to rename them all into
1a.txt
1b.txt
1c.txt
2a.txt
2b.txt
2c.txt
in a way I just need to remove first 2 digits and a space character. i haven't been successful. any tips?
thank you
well, i don't think my script will be able to do that in one single run but if you are familiar with DOS commands and any spreadsheet apps you might be able to pull this through
first run a DIR command on the files you wish to rename then paste the results into an spreadsheet application.
on the first column of the spreadsheet, you may type in the DOS command for rename which is REN.
on the second column, paste in the returns from your DIR command.
on the third column add in the new filenames right beside its current filename.
with spreadsheet manipulation it would be easy to generate the newfilename.
on the fourth column, using some spreadsheet commands to append column A and column B and column C into column D.
Column D should produce something like this:
REN 01 1a.txt 1a.txt
REN 02 1b.txt 1b.txt
now, select the column D, and paste it into a text file then save it as a batch file. place it on the same folder with the files you wish to rename. and run it.!
I hope that helps. you will need to know some basic batch and DOS commands before you will be able to do this.
Their editor commands are powerful and a script, once developed, will work in all windows versions. _?