(Redirected from Deleting files with special characters in their names, in Windows)
A couple of directories in Windows couldn’t be deleted by Windows Explorer, because they had unprintable characters (I’m assuming) in their names.
D:\tmp>dir Volume in drive D is Data Volume Serial Number is 8C47-34BD Directory of D:\tmp 28/09/2012 11:34 AM <DIR> . 28/09/2012 11:34 AM <DIR> .. 26/10/2010 01:51 PM <DIR> 954321. 0 File(s) 0 bytes 3 Dir(s) 89,164,262,548 bytes free
<p> On on hitting <kbd>Delete</kbd> it replied “Could not find this item. This is no longer located in D:\tmp”. I tried on the command line, a similar error: </p> <pre lang="DOS">
D:>rd 954321. The system cannot find the file specified.
<p> The security properties of the folder looked weird, saying “The requested security information is either unavailable or can’t be displayed.”: </p> <p> <img src="http://samwilson.id.au/wp-content/uploads/2012/09/properties.png" alt="A screenshot of the top part of the properties dialog, showing the Security tab." width="385" height="143" /> </p> <p> So I faffed around trying to change ownership, filenames, etc. all with no luck. Nothing seemed to see these files as existing except for Windows Explorer and <code>ls -force</code>. </p> <p> In the end <a href="http://superuser.com/a/31684/14134" title="How to force Windows XP to rename a file with a special character?">Superuser came to the rescue</a>, as it often does, with the suggestion of referring to the file by its shortname, which can be got via <code>dir /x</code>. </p> <pre lang="DOS">
D:>rd /s 9543211 9543211, Are you sure (Y/N)? y
<p> Agh. Why are the simple things so hard to remember sometimes?… </p>