tags:

views:

37

answers:

2

Can't seem to nail this one down... Is there a programmatic/batchish way to rename a set of files in the same directory from 1_body.html, 2_body.html, etc to 1.html, 2.html?

I'm just a regular user, so I wont have permissions to do anything too fancy :).

+1  A: 

As it always seems to go, after hours of digging I found the answer right after posting this...

rename ?_body.html ?.html
rename ??_body.html ??.html
rename ???_body.html ???.html

Took care of it.

Bob
+1  A: 

You could also do it using VBScript. Here's an example (based on this script):

Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")  ''# Current directory
Set objFolder = objFSO.GetFolder(strFolder)
For Each strFiles In objFolder.Files
    If objFSO.GetExtensionName(strFiles) = "html" Then
        strComponents = Split(strFiles.Name, "_")
        strFiles.Name = strComponents(0) + ".html"
    End If
Next

Save the above as something.vbs in the directory it is to run and double click to run it.

To format code, indent it four spaces, or select it and click the code button (101010) on the editor's toolbar.
Helen
Very cool, I want to save this for later
Bob