Wednesday, January 13, 2010

How to rename and delete files and/or folders saved with invalid files names, such as with a period . or a space at the end of the file or folder name

How to rename and delete files and/or folders saved with invalid files names, such as with a period . or a space at the end of the file or folder name

To delete a file or folder with a space at the end of its name (or any name that contains special characters), do as follows in the command window (execute cmd.exe)

Go to the containing directory.

dir /X

lists you all files in long as well as abbreviated names, e.g. FILE~1

rename the file using the abbreviated name to something, and delete it, e.g.
ren FILE~1 asdf
del asdf

1 comment:

Desktop Dude said...

Was able to use this method above to rename invalid FOLDER names, but it would not budge for FILE names. I tried different variations of the "DIR /X" short name to rename but it just didn't work. Figured this came from a Mac, I'd use a Mac and change/move these files. BOTH my Macs one running 10.5.x and the other running 10.6.x didn't work. When I click on the file name the file just disappears from view. What did finally help me rename these files was a 10.4.x Mac Mini on a Power PC. Strange because the 10.4 didn't like the names either since it would not move or copy it as it. But it was able to rename it. Since I only had like 20 files to rename it wasn't that bad.