Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Will it let you rename them or move them to a different location? If you can move them, try putting them all in one directory, then deleting that directory. –  nhinkle Jul 19 '10 at 18:16
    
Technically, they are valid, it is Windows Explorer that is invalid^W special needs file manager. –  Alexei Averchenko Jul 26 '13 at 7:43

4 Answers 4

up vote 5 down vote accepted

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.

share|improve this answer
    
@Hello71 (to @Ruggle Humsteader) - new users can't comment, they can only answer (they presently need 50 rep points for that: superuser.com/faq ). They can comment on their own questions and answers, though. (Just so other new users aren't confused by your request.) –  michael_n Mar 29 '11 at 14:28
    
How would you make such a file from Windows? –  ekaj Jul 26 '13 at 4:29
    
@ekaj - the file could be created using another OS. Create a screenshot in Ubuntu, it has colons in the filename. Then open it in Windows - that won't work. –  SPRBRN Jul 26 '13 at 8:01
    
@rxt I'm aware. My point is if you can delete it, you can probably make it some how. –  ekaj Jul 26 '13 at 14:49
1  
doesn't work for me in Windows 7 –  Populus Jan 25 at 23:35

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

share|improve this answer
    
Yesterday I saved a screenshot in Ubuntu, then tried to open that in a Windows VM. It refused to open, bad file type or something. Then I realised it could be the colon in the filename, which I couldn't remove in Windows. I change the name in Nautilus, and then I could open the file. –  SPRBRN Jul 26 '13 at 7:59

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.

share|improve this answer
1  
If you regularly deal with unix files on a windows machine, it's always a good idea to have cygwin installed. Otherwise it might suit you better to boot and delete the file from a linux live CD when the situation arises. –  Marnix A. van Ammers Jul 19 '10 at 19:42
1  
Unfortunately, I have tried cygwin, and that does not help. 8-{ Even cygwin is not able to remove the files. –  hstoerr Jul 20 '10 at 7:02
3  
cygwin tools still relies on the windows API to delete files. If the Windows API refuses the filename, nothing can be done from Windows with standard file tools. I also recommend to access the filesystem from an alternate OS. –  dolmen Mar 26 '11 at 21:09

To fix this on Windows 7:

chkdsk C:/r
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.