开发者

Windows Batch to rename <int>_body.html to <int>.html

Can't seem to nail this one down... Is there a programmatic/batchish way to rename a set of files in the same direc开发者_Python百科tory 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 :).


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜