2008 Mar 15

Mass rename files using wscript

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")

0 TrackBacks

Listed below are links to blogs that reference this entry: Mass rename files using wscript.

TrackBack URL for this entry: http://www.tildemark.com/cgi-bin/mt4/mt-tb.cgi/104

Leave a comment

About this Entry

This page contains a single entry by tildemark published on March 15, 2008 8:22 AM.

Laser for your Eyes was the previous entry in this blog.

Stand alone flash player is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Recent Activity

Friday

  • tildemark tweeted, "im so sleepy. Zzzzzzzz"

Sunday

  • tildemark tweeted, "some of my scipts are not working with godaddy. but works fine on the others. not mention their poorly coded admin page"

Today

  • tildemark tweeted, "so many pending tasks i need to finish. need more coffee !!!"
  • tildemark tweeted, "@gmtristan i dont think that is true."

Today

  • tildemark tweeted, "how does godaddy subdomain behaves? i have some problems with it on my scripts. it does not seem to accept query strings.."

Monday

  • tildemark tweeted, "i had a hard time removing the error messages generated by surf side kick. i ended up uninstalling most of my applications."

Sunday

  • tildemark tweeted, "i got hit by surf side kick and im getting numerous error messages on my screen. tskkkkk"

Saturday

  • tildemark tweeted, "check boxes, i didn't know they can also be complex"
  • tildemark tweeted, "this smart bro internet speed is depressing, i thinking of filling a complaint to the DTI next week."

Friday

  • tildemark tweeted, "the seminar turned out to be leadership training. it was fun, learned alot. i have already attended numerous seminars but this is different."