Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Files with illegal filenames

I've accidentally created -?.tgz file on my NTFS hdd (working under linux). And I'm just curious is it possible to delete it under Windows 7 using standard tools?

Things I've tried:

1) move *.tgz die.tgz gave me same error "The file name you specified is not valid or too long"

2) File had no short windows name, so I was not able to delete it using short name

share|improve this question

migrated from Apr 9 '12 at 14:32

This question came from our site for professional and enthusiast programmers.

marked as duplicate by random Apr 24 '12 at 4:22

This question was marked as an exact duplicate of an existing question.

Actually looks like a dupe - I've flagged as such and removed my answer – dsolimano Apr 24 '12 at 4:18

Have you tried putting double quotes around the file name?

You can also try typing "del " then keep pressing Tab when you are in the same directory as the file - this will loop through the files in that folder.

share|improve this answer
It's worth a try. – Alex Apr 7 '12 at 5:21

It's only a suggestion because I can't try now.
In the past I have gotten rid of files with invalid names
(mainly files with a terminating space) with this command:

del "\\?\c:\full_path_to_file\-?.tgz"
share|improve this answer
This is the 2nd time in a few days I've seen posts with path syntax like \\?` and \-?`. It is new to me. Can you give an explanation and/or reference? – dbenham Apr 6 '12 at 13:33
@dbenham: MSDN? – Alex Apr 6 '12 at 13:56
@Alex thanks for the link. Very complete. – Steve Apr 6 '12 at 14:12
@dbenham The weird filename has been created with Linux on a Windows Partition. I have used that syntax to remove files with an added space at the end of the name. In the Alex link you will find all the details – Steve Apr 6 '12 at 14:13
C:\Users\Anton>del "\\?\D:\temp\-?.tgz" \\?\D:\temp\-?.tgz The filename, directory name, or volume label syntax is incorrect. doesn't work – Viller Apr 6 '12 at 14:26

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