I have some files with long filenames
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
that I would like to pad with zeroes so they look like
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
and be able to use wild cards for the file names.
I've been using this script but it only adds the zeros I put in and doesn't accept wildcards:
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
So with that script, long filename with spaces 1.jpg
becomes long filename with spaces 0001.jpg
, which is what I want, but long filename with spaces 125.jpg
becomes long filename with spaces 000125.jpg
, which isn't what I'm looking for.
I'm using Windows 10 and I would also accept batch files.