Deleting files with special characters in their names, in Windows

(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 &#8220;Could not find this item.  This is no longer located in D:\tmp&#8221;.  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 &#8220;The requested security information is either unavailable or can&#8217;t be displayed.&#8221;:
  </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?&#8230;
  </p>


Retrieved from ‘https://samwilson.id.au/index.php?title=Deleting_files_with_special_characters_in_their_names,_in_Windows&oldid=142