Cadzow Knowledgebase


Welcome
Contact Us
Professional
Services

Consulting
Knowledgebase/
Site Search

Remote Support

Print Friendly

Deleting Undeletable Files

The Windows NTFS file system allows the creation of paths and filenames which are very long and contain exotic characters beyond the usual ASCII character set (a, b, c, 1, 2, 3, etc). However, most of the utilities in Windows, such as Windows Explorer, and the DEL and ATTRIB commands, cannot deal with such long paths and/or characters because they filter the filenames before passing to the file system API. This means that it is possible to create files which cannot be removed, or dealt with in any other way.

Another cause of undeletable files are those with a space at the end of the filename. (When deleting a folder, if a file or folder contained in folder that has a space at the end of the name, the operation will silently quit.)

Using Robocopy To Remove Unwieldy Filenames

Robocopy, unlike many of the inbuilt commands, supports much longer paths.

  1. Suppose the folder containing the files to be deleted is C:\FILES.

    Make another folder, and move all of the files to be retained into it, so only the files to be deleted are in C:\FILES.

  2. At a command prompt, type:

    ROBOCOPY C:\WINDOWS C:\FILES /MIR

    The /MIR command makes a mirror of the source folder into the destination folder, including removing files which are not in the source folder. Thus Robocopy will first remove all the files in C:\FILES regardless of their names or attributes, then copy the contents of C:\WINDOWS.

    The Robocopy command can be cancelled with Ctrl-C almost immediately as the deletion operation will be done first.

  3. Remove the newly-copied files from C:\FILES and rearrange the files moved out from step 1.

Using Short Names To Remove Problematic Files

If you've identified a file or folder with a problematic filename, or one which has a space at the end:

  1. Open a command prompt and navigate to the root location:

    cd C:\Data\Folder

  2. Enter a directory listing command:

    dir /x

    This will list the files with their generated 8.3 (DOS-compatible) names:

    03/06/2015  05:21 PM    <DIR>          SHELLE~1     shellext

  3. Delete the file (or remove the folder) using the short name:

    rd SHELLE~1

  4. If renaming, use a temporary name first, as the corrected filename may conflict with the corrupt name:

    ren SHELLE~1 TempFolder
    ren TempFolder Shellext

Copyright © 1996-2019 Cadzow TECH Pty. Ltd. All rights reserved.
Information and prices contained in this website may change without notice. Terms of use.


Question/comment about this page? Please email webguru@cadzow.com.au