我有一個長文件名填充索引並接受通配符
long filename with spaces 1.jpg long filename with spaces 1.bmp long filename with spaces 2.jpg long filename with spaces 2.bmp long filename with spaces 3.jpg long filename with spaces 3.bmp ... long filename with spaces 10.jpg long filename with spaces 10.bmp long filename with spaces 11.jpg long filename with spaces 11.bmp ... long filename with spaces 124.jpg long filename with spaces 124.bmp long filename with spaces 125.jpg long filename with spaces 125.bmp
一些文件,我想墊零,使他們看起來像
long filename with spaces 0001.jpg long filename with spaces 0001.bmp long filename with spaces 0002.jpg long filename with spaces 0002.bmp long filename with spaces 0003.jpg long filename with spaces 0003.bmp ... long filename with spaces 0010.jpg long filename with spaces 0010.bmp long filename with spaces 0011.jpg long filename with spaces 0011.bmp ... long filename with spaces 0124.jpg long filename with spaces 0124.bmp long filename with spaces 0125.jpg long filename with spaces 0125.bmp
,並能夠使用文件名的通配符。
我一直在使用這個劇本,但它只是增加了零點,我把和不接受通配符:
Set objFso = CreateObject("Scripting.FileSystemObject")
Set Folder = objFSO.GetFolder("C:\MyPictures\")
For Each File In Folder.Files
sNewFile = File.Name
sNewFile = Replace(sNewFile, "long filename with spaces ", "long filename with spaces 000")
If (sNewFile <> File.Name) Then
File.Move(File.ParentFolder + "\" + sNewFile)
End If
Next
與腳本
所以,long filename with spaces 1.jpg
變得long filename with spaces 0001.jpg
,這是我想要的,但long filename with spaces 125.jpg
變成long filename with spaces 000125.jpg
,這不是我正在尋找的。
我使用的是Windows 10,我也接受批處理文件。
兩個很好的答案和我喜歡的評論.. – joetex72
如果這個腳本沒有提示每次我都會喜歡,所以我可以從批處理文件@ mc-nd調用它。 – joetex72
@ joetex72,如果您不需要輸出,請刪除'WScript.Echo'這行代碼,或者如果您要從批處理文件中使用它,請將其作爲'cscript.exe // nologo myScript.vbs'運行。如果不想刪除'Echo's,但不希望輸出使用'cscript.exe // nologo // b myScript.vbs'(控制檯模式)或'wscript // b myScript.vbs'(窗口模式)。 '// b'將以*「批處理」*模式運行腳本(在批處理的意義上,而不是批處理文件),壓縮所有輸出。 –