17

I've got a rather large number of files on my Windows drive that have a colon in their name. (These came from unpacking some Unix archives.)

When I try to delete them, Windows (XP) complains that the file does not exist, and refuses to delete it. This happens when trying to delete or rename it from explorer or the command line. Still, chkdsk does not complain about those files nor fix the problem.

Any ideas on how to get rid of them?

Mithical
  • 321

7 Answers7

11

You may be able to use this syntax (per Microsoft KB 320081):

del "\\?\c:\path_to_file\bad:name.ext"

See also this serverfault question on the same topic, "delete file containing invalid characters in windows".

I think the old "ntfsdos" sysinternals utilities could remove/rename these files as well, but these are no longer available post-MS acquisition.

michael
  • 1,161
8

You may want to try booting from an Ubuntu Live CD and deleting it from there.

slhck
  • 235,242
Tofystedeth
  • 655
  • 5
  • 10
6

Close all the files, if any opened, that are saved in the drive which is containing such files. Now, Open the drive properties.

"My Computer" -> "Right Click on the this drive" > properties

Then, go to "Tools" tab and click "Check now" under 'Error checking' label.

[Click here for image]()

This will unmount your drive and will scan the complete drive for errors, eventually it will delete such files with illegal names. On finishing it will show a messages saying some files were fixed.

I successfully deleted such files from my external hard disk.

Nifle
  • 34,998
1

If everything else fails, you may need to edit the name directly in NTFS.

I've done it successfully with Active@ Disk Editor. Proceed with caution.

  • open the program
  • choose Explore My Computer
  • find your file
  • choose Inspect File Record on the button bar or in the context menu
  • enable Allow Edit Content in the Edit dropdown menu or in the context menu
  • find the name in the Unicode column and click on it, overwrite bad symbols with a good one, like a character or a dash. Remember what and how you renamed, you'll need it in the next step.
  • return to the My Computer tab
  • select file's parent directory in the tree view
  • choose Inspect File Record on the button bar or in the context menu
  • in the tree view on the left find Attribute $A0 (in bold), open it, find $INDEX_ALLOCATION, Data run, First cluster, click on the value, it should be interactive.
  • find the name and edit it in the same way as in the previous step. You may need to scroll down a bit to find it if there are many files in the directory.
  • if you're sure you didn't accidentally overwrite any other data, click Save. Otherwise, close the tab without saving the changes and carefully do everything again.
  • reboot.

If the file or directory is still inaccessible, try chkdsk now.

user
  • 1,290
1

You can easily do it in the command line (CMD) without any fancy programs.

  1. Rename the file/folder using the old short notation (e.g. for Filename, FILENA~1) and. To get the notation, navigate to the directory containing the folder/file with an invalid name, and type:

    dir /x

  2. Rename to a valid name by using:

    ren FILENA~1 fileName

  3. Now erase the valid file/folder in either CMD or in Windows explorer:

    del fileName

1

To fix this on Windows 7:

chkdsk C:/r
tpbapp
  • 111
-2

Another alternate that you may want to try is to bring in CygWin, a bash shell for windows. This would allow you to apply UNIX commands to your DOS folders.

Dave
  • 614