批量重命名图像?[重复]


Answers:



0

假设纯Windows(即没有Cygwin等),并且你不想或不想安装任何东西,我建议使用Visual Basic脚本来完成这项工作。您可以尝试以下方法:

 targetDir = WScript.Arguments.Item(0)
 WScript.Echo "Operating on files in " + targetDir
 Set fsh = CreateObject("Scripting.FileSystemObject")
 Set targetFiles = fsh.GetFolder(targetDir).Files
 ZeroPadWidth = Len(targetFiles.Count)
 FileNumber   = 0
 For Each File In targetFiles
   FileNumber = FileNumber + 1
   NewName = targetDir & "\"
   For I = 1 To ZeroPadWidth - Len(FileNumber)
     NewName = NewName & "0"
   Next
   NewName = NewName & FileNumber
   WScript.Echo "Renaming " & targetDir & "\" & File.Name & ": " & NewName
   File.Move(NewName)
 Next

把它放到一个文件中,例如“rename.vbs”; 然后,从命令行调用它,目标目录作为唯一参数,如下所示:

 c:\Users\Username\Desktop> cscript rename.vbs "c:\target\directory"

它将生成文件名,这些文件名按数字排序并用零填充左边; 如果你有一个包含一千个文件的目录,你将得到名称范围从0001,0002 ... 0999,1000。

没有保修,但它应该做你需要的。如果没有,请告诉我。(并制作目标目录的安全副本以防万一;我已经测试了一下,它应该没问题,但总有可能出现我没有抓到的bug。)

希望这可以帮助!(如果确实如此,我希望你能够接受Shinrai关于接受率的观点。)

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.