Removing Spaces from Filenames on Windows

I received 60 documents to put online, beautifully named, but with SPACES!!! Aaaah!

Thankfully, you can bulk remove them in a powershell: hooray! This simple, understandable and beautiful solution on Stack Overflow shows you how:

  • Open the command prompt, by searching for CMD
  • Open a powershell by typing in powershell
  • cd to the folder the files are in
  • and try this command
    get-childitem *.pdf | foreach {rename-item $_ $_.name.replace(" ","")}
    replace pdf with whatever the relevant extension is

That’s it, works beautifully!

Photo credit: de moi, 2020.

Leave a Comment