Deleting folders with trailing spaces in Windows

The other day I came across a folder on my laptop that I couldn’t delete. It seems that an application had created it with a trailing space and as you are probably aware once a folder is created with a trailing space in Windows it’s almost impossible to delete or rename.

Well… after searching google and scrapping every forum I could find I came across this command [link]. I was able to use it to remove the folder and get on with my life:


i.e. RD “\\?\C:\Invalid Folder “

To save myself the agony of looking for it up again (and hopefully make your search a little less time consuming) I made this post. Hope it helps!