5

I am trying to delete a file named "Kanno, Yoko - Where Does This Ocean Go?.mp3" from my hard drive in Windows 7 Ultimate x64 and it keeps telling me that it cannot because the file name is too long or invalid (due to the "?" in it). I cannot rename it, cannot delete it, cannot do so either with Explorer or with CMD. I also cannot delete the folder containing it either with Explorer or with CMD.

Does anyone have an answer or suggestion to try? I have no idea how such a name ever got created in the first place (software to rename files according to their title, but still, it should not have been saved with an invalid name like that). Regardless, how can I now get rid of it?

migrated from stackoverflow.com May 25 '12 at 21:58

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

  • A file cannot be created or renamed using a filename that contains a '?' character. It is a reserved wildcard character. Maybe your filesystem got corrupted at the hardware layer. – Remy Lebeau May 24 '12 at 21:35
  • It's only a widcard to shell input. AFAIK the disk sub-system calls don't care. – starbolin May 24 '12 at 21:40
  • @star Windows APIs will all object to that filename – David Heffernan May 24 '12 at 21:42
  • 2
    The GUI shells in Linux may object but I doubt that the command line shells do. *nix has always allowed wildcards, suitably escaped, in filenames. – David Heffernan May 25 '12 at 5:54
  • 1
    A file on a typical Unix/Linux filesystem can indeed contain special characters. You can specify such a filename on the command line either by enclosing it in quotes, or escaping the special characters. Example: vi whatFileIsThis\?.txt or vi "whatFileIsThis?.txt" On Linux, the wildcard expansion is actually done by the shell rather than the application - the file APIs don't handle wildcards at all, as opposed to Windows where they do. This explains why your Android device was able to manipulate the file where Windows couldn't. – fdmillion Sep 15 '15 at 15:17
3

Microsoft has an Article about hard to delete files.

Most of the time for me, prepending the path with \\?\ does exactly what I want. So you could try del "\\?\c:\path\Kanno, Yoko - Where Does This Ocean Go?.mp3"

There is also \\.\ and I don't know what the exact difference to \\?\ is.

Both prefixes seem to disable some checks and/or make del use lower level APIs than the usual Win32 API.

2

Resolved: I plugged the hard drive into an external casing and connected it via USB to my Android tablet as a USB drive. Using my Android File Browser, I navigated to that file and deleted it. Android will not let you name files with "?" in them either, nor could I play that file while it had an "?" still in it, but Android let me rename/copy/move/delete it, so problem solved, just not with Win7. FYI, I could play the mp3 file just fine once I removed the "?" from the name.

1

I just did this and I'm only answering to help others on Windows 7-10. I literally opened the location of the file in Winrar and changed its name, only because the windows file manager could not change the name due to it having an invalid character. After changing its name I deleted the file. EZPZ also, good music choice I love Ghost in the Shell!

0

Try this from the command line:

del Kanno*.mp3

Or perhaps try to find the short name of the file and delete that. I think dir /x will list the short names, but my recollection is hazy.

The only thing I can imagine that might produce that is an invalid character encoding. When the system encounters text that has been encoded incorrectly it can display as "?".

Windows is more careful about not allowing wildcards in filenames that some other systems. Many years ago I remember a colleague making a file named * on a UNIX system. That incident did not end with smiles.

  • 1
    del * does not work. That was my original problem as the entire folder was being deleted. "dir /x" did not list any short name for the file even though there is a space in the first 8 characters. – Uncle Code Monkey May 25 '12 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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