Skip to content

Instantly share code, notes, and snippets.

@gavD
Created August 15, 2012 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavD/3358134 to your computer and use it in GitHub Desktop.
Save gavD/3358134 to your computer and use it in GitHub Desktop.
VBScript to recursively remove spaces from filenames in a directory
Dim fso : Set fso = WScript.CreateObject("Scripting.FileSystemObject")
sub fixFolder(path)
Dim fol : Set fol = fso.GetFolder(path)
For Each fil In fol.Files
If InStr(1, fil.Name, ".bxl") <> 0 Then
If InStr(1, fil.Name, " ") <> 0 Then
dim newName : newName = Replace(fil.Name, " ", "")
fil.Name = newName
End If
end if
Next
for each Subfolder in fol.SubFolders
fixFolder(Subfolder.Path)
next
end sub
fixFolder(".")
WScript.Echo "Completed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment