3

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

Viller
  • 206

2 Answers2

2

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"
Steve
  • 256
  • 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 06 '12 at 13:33
  • 2
    @dbenham: MSDN? –  Apr 06 '12 at 13:56
  • @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 06 '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

    –  Apr 06 '12 at 14:26
  • @Alex @Steve - Thanks, the link is exactly what I was looking for. I see how it enables working with names that end with space or dot. But it does not help with reserved characters like ?*<>/\|:", (not from the command line, anyway). – dbenham Apr 06 '12 at 15:21
  • @dbenham there is this utility - DelInvFile, but now is no more free – Steve Apr 06 '12 at 15:52
  • I also wonder if any disk check/repair utilities can detect and fix the problem. The cheapest solution might be to boot again into Linux and delete the file from there. –  Apr 07 '12 at 05:22
0

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.