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 have a song that Windows can't play because there is a question mark in the name of the file.

"Where Have All the Cowboys Gone?.ogg" // as an example

So I try to rename it and Windows complains whether I try it in Explorer or from command prompt.

Error I get when trying to copy, rename, or move is:

The Filename, directory name, or volume label syntax is incorrect

Is there a Windows way to force a rename in this case?

Update

I'll keep an eye on this question, but after 13 answers and many attempts (aside form 3rd party solutions) it seems that Windows can't do this (or at least my windows can't, no short names). So I'm accepting the answer which was my original solution anyway of using Linux. It would be nice to see Windows handle this somehow, so don't stop just because I've accepted this answer, the question still stands!

share|improve this question
3  
May I ask how you got to this state? Windows generally won't let you do this. –  Michael Kohne Aug 28 '09 at 19:55
10  
you may ask... :-) –  codeLes Aug 28 '09 at 19:59
show 6 more comments

26 Answers 26

up vote 19 down vote accepted

Grab a linux live-cd and use that.

share|improve this answer
1  
recent linux distros like ubuntu successfully support the most important features of NTFS. –  Atmocreations Aug 30 '09 at 19:31
1  
Ubuntu 9.04 is absolutely flawless at NTFS support, with one or two annoyances (like if there's a power cut, and you boot into ubuntu to save a few seconds boot time, you can't access your windows partition until you boot back into it) –  Phoshi Sep 2 '09 at 16:59
show 4 more comments

Have you tried using the short filenames version of its name? Eg

ren whereh~1.ogg where.ogg

If it's the only file in the current folder that starts with the first few letters, then use the first 6 letters of the name (ignoring spaces) followed by a tilde (~) then a 1.

share|improve this answer
8  
Since generation of short names is optional depending on how Windows is currently configured, Murphy says that the OP has short names turned off and the file won't have one. To learn the short name if it is present for any file, use DIR/X which will add a column showing the short name for any file where it differs from the long name, if it has one at all. If there is a short name, this would be a plausible answer. –  RBerteig Aug 28 '09 at 22:18
1  
no short names, tried your example and also the dir/x proves that there aren't any listed. –  codeLes Sep 2 '09 at 15:33
show 1 more comment
  1. In Windows 7: Run cmd.exe in Administator Mode.
  2. cd into the Directory with the filenames.
  3. run: chkdsk /V /f [My bad files were on another drive other than the OS drive, so it was able to dismount it. If it is the OS drive, it may have to do this stage at startup.]
  4. Wait (May have to reboot).

As you will see the result was that chkdsk actually deleted the files for me. So, if you want to keep the files, I don't know what to do, but this will get rid of the files for sure.

Results/Cmd Log:

E:\islag\Music\llb>dir
 Volume in drive E is FreeAgent Drive
 Volume Serial Number is 5038-892A

 Directory of E:\islag\Music\llb

02/02/2011  12:18 PM    <DIR>          .
02/02/2011  12:18 PM    <DIR>          ..
04/04/2010  02:19 PM         4,014,099 01 Los Lonely Boys - Se?orita - www.file2
4ever.com.mp3
04/04/2010  02:18 PM         3,125,942 12 Los Lonely Boys - La Contestaci?n - ww
w.file24ever.com.mp3
               2 File(s)      7,140,041 bytes
               2 Dir(s)  87,743,991,808 bytes free

E:\islag\Music\llb>chkdsk /V
The type of the file system is NTFS.
Volume label is FreeAgent Drive.

WARNING!  F parameter not specified.
Running CHKDSK in read-only mode.

CHKDSK is verifying files (stage 1 of 3)...
  231424 file records processed.
File verification completed.
  34 large file records processed.
  0 bad file records processed.
  0 EA records processed.
  0 reparse records processed.
CHKDSK is verifying indexes (stage 2 of 3)...
18 percent complete. (29338 of 245164 index entries processed)
An invalid filename 01 Los Lonely Boys - Se?orita - www.file24ever.com.mp3 (3196
6) was found in directory 31962.
All filenames for File 31966 are invalid.
Minor file name errors were detected in file 31966.
An invalid filename 12 Los Lonely Boys - La Contestaci?n - www.file24ever.com.mp
3 (31973) was found in directory 31962.
All filenames for File 31973 are invalid.
Minor file name errors were detected in file 31973.
73 percent complete. (233817 of 245164 index entries processed)
Index entry 01 Los Lonely Boys - Se?orita - www.file24ever.com.mp3 in index $I30
 of file 31962 is incorrect.
Index entry 12 Los Lonely Boys - La Contestaci?n - www.file24ever.com.mp3 in ind
ex $I30 of file 31962 is incorrect.
  245164 index entries processed.
Index verification completed.

Errors found.  CHKDSK cannot continue in read-only mode.

E:\islag\Music\llb>dir
 Volume in drive E is FreeAgent Drive
 Volume Serial Number is 5038-892A

 Directory of E:\islag\Music\llb

02/02/2011  12:18 PM    <DIR>          .
02/02/2011  12:18 PM    <DIR>          ..
04/04/2010  02:19 PM         4,014,099 01 Los Lonely Boys - Se?orita - www.file2
4ever.com.mp3
04/04/2010  02:18 PM         3,125,942 12 Los Lonely Boys - La Contestaci?n - ww
w.file24ever.com.mp3
               2 File(s)      7,140,041 bytes
               2 Dir(s)  87,743,991,808 bytes free

E:\islag\Music\llb>chkdsk /V /f
The type of the file system is NTFS.
Cannot lock current drive.

Chkdsk cannot run because the volume is in use by another
process.  Chkdsk may run if this volume is dismounted first.
ALL OPENED HANDLES TO THIS VOLUME WOULD THEN BE INVALID.
Would you like to force a dismount on this volume? (Y/N) y
Volume dismounted.  All opened handles to this volume are now invalid.
Volume label is FreeAgent Drive.

CHKDSK is verifying files (stage 1 of 3)...
  231424 file records processed.
File verification completed.
  32 large file records processed.
  0 bad file records processed.
  0 EA records processed.
  0 reparse records processed.
CHKDSK is verifying indexes (stage 2 of 3)...
18 percent complete. (29339 of 245164 index entries processed)
Deleted invalid filename 01 Los Lonely Boys - Se?orita - www.file24ever.com.mp3
(31966) in directory 31962.
File 31966 has been orphaned since all its filenames were invalid
Windows will recover the file in the orphan recovery phase.
Correcting minor file name errors in file 31966.
Deleted invalid filename 12 Los Lonely Boys - La Contestaci?n - www.file24ever.c
om.mp3 (31973) in directory 31962.
File 31973 has been orphaned since all its filenames were invalid
Windows will recover the file in the orphan recovery phase.
Correcting minor file name errors in file 31973.
73 percent complete. (233642 of 245164 index entries processed)
Deleting index entry 01 Los Lonely Boys - Se?orita - www.file24ever.com.mp3 in i
ndex $I30 of file 31962.
Deleting index entry 12 Los Lonely Boys - La Contestaci?n - www.file24ever.com.m
p3 in index $I30 of file 31962.
  245164 index entries processed.
Index verification completed.
CHKDSK is scanning unindexed files for reconnect to their original directory.
  2 unindexed files scanned.
CHKDSK is recovering remaining unindexed files.
  2 unindexed files recovered.
CHKDSK is verifying security descriptors (stage 3 of 3)...
  231424 file SDs/SIDs processed.
Cleaning up 41 unused index entries from index $SII of file 9.
Cleaning up 41 unused index entries from index $SDH of file 9.
Cleaning up 41 unused security descriptors.
Security descriptor verification completed.
  6871 data files processed.
CHKDSK is verifying Usn Journal...
  1116928 USN bytes processed.
Usn Journal verification completed.
Correcting errors in the master file table's (MFT) BITMAP attribute.
Windows has made corrections to the file system.

 244196000 KB total disk space.
 158175168 KB in 30003 files.
     22820 KB in 6873 indexes.
         0 KB in bad sectors.
    306168 KB in use by the system.
     65536 KB occupied by the log file.
  85691844 KB available on disk.

      4096 bytes in each allocation unit.
  61049000 total allocation units on disk.
  21422961 allocation units available on disk.

E:\islag\Music\llb>dir
 Volume in drive E is FreeAgent Drive
 Volume Serial Number is 5038-892A

 Directory of E:\islag\Music\llb

02/02/2011  12:18 PM    <DIR>          .
02/02/2011  12:18 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  87,743,979,520 bytes free

E:\islag\Music\llb>
share|improve this answer
add comment

Try specifying the unicode path. This gets around all sorts of restrictions. You would do it using the \?\ syntax.

Example, if your file was on your desktop (and your Windows drive is C:) you can do

copy "\\?\C:\Users\codeLes\Desktop\Where Have All the Cowboys Gone?.ogg" "\\?\C:\Users\codeLes\Desktop\Where Have All the Cowboys Gone.ogg"

Note: You can't use relative paths with this syntax you must specify the full path and it does not work with the ren command but does work with copy and move.

share|improve this answer
1  
gave it a try, not luck "The filename, directory name, or volume label syntax is incorrect." Thanks! I'm getting to the point where I think the correct answer is to use Linux to rename it (which I have done). –  codeLes Sep 2 '09 at 15:37
add comment

chkdsk will sometimes fix invalid file names. You will get a message about removing the file because all the file names are invalid, and then recovering a lost file. You can then find the file in C:\found.000\file0000.chk. This is an effective way to remove the problem files, but not the best way if you want to keep them.

share|improve this answer
add comment

Have you tried moving it to a file with the right name?

move "Where Have All the Cowboys Gone?.mp3" "Where Have All the Cowboys Gone.mp3"
share|improve this answer
1  
tried, no luck. "The Filename, directory name, or volume label syntax is incorrect" –  codeLes Aug 28 '09 at 19:51
show 1 more comment
  • If it's more than 1 file, create new directory with a simple name, for example a.
  • Move one single file each time to that directory.
  • In cmd.exe go to the new directory and type the following:

    ren *.ogg 1.ogg   
    

    This is for simplicity. Then you can rename it in XP as you want, like 1.ogg to Where Have All the Cowboys Gone.ogg. ogg was just an example, extension can be anything.

share|improve this answer
add comment

Try a wildcard on the move -

move "Where Have All the Cowboys Gone*.mp3" "Where.mp3"

That's probably your best bet, as long as there is only one file that matches the wildcard.

share|improve this answer
show 3 more comments

Assuming the volume in question is FAT32 or NTFS, try running chkdsk. That should clean up 'corrupted' directory entries, which would (in this case) mean removing the ?. If it's the boot volume, you might need a reboot to do it.

share|improve this answer
show 1 more comment

Try using a third party tool such as the Ken Rename tool:

Screenshot of Ken Rename

or Rename Master.

enter image description here

Here's a list of file renaming tools.

I'd test them myself, but I'm running Windows Vista 64-bit; the file handling may be different.

If those tools fail, you may want to give Windows PowerShell a shot. See Renaming Files on the Windows PowerShell Blog.

share|improve this answer
show 2 more comments

If you have Cygwin installed it should be able to take care of the file. I had that problem just now and using rm from Cygwin in a bash shell was able to delete the file just fine when no Windows app, including Explorer and including trying to use the UNC filespec with CMD.exe helped.

I would imagine that mv would do it to in case you wanted to keep the file.

A barebones Cygwin setup only takes a few minutes, and I always keep it around anyway because there are so many good tools. It's easier than booting Linux, even using a live CD.

share|improve this answer
show 1 more comment

Use Recuva. It is primarily intended for recovering deleted files but it also has an option for including non-deleted files in its scan.

After launching Recuva, refuse the wizard and select the right disk. Then go to Options, find and check the option (i.e. searching for non-deleted files) and launch the scan. After a while, it will show all the files on the disk (whether deleted or not). Find your files with invalid names (the names are already fixed in the view), select them, right click and save somewhere.

I have just done it (on Windows XP).

share|improve this answer
add comment

drag and drop to a new folder, navigate in command prompt to that folder and type

ren *.* test.ogg
share|improve this answer
6  
Conversely you could try moving everything else out of the folder in question. –  therefromhere Sep 2 '09 at 16:58
show 1 more comment

If you have Winrar. Pack it on WinRar, rename it on WinRar, unpack it.

[EDIT TO ADD]

Or you can try with a vbs script, take next script and save it under a file with vbs extension.

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

fso.MoveFile "Where Have All the Cowboys Gone?.ogg", "Where.ogg"
share|improve this answer
2  
I don't have WinRAR at work and my work machine is not on the net. I do have 7zip, anyway I can do that with 7zip, just tried and it wouldn't let me add it to the archive... same error :-) –  codeLes Aug 28 '09 at 19:58
show 6 more comments

The Microsoft tool DISKEDIT.EXE is a low-level tool for directly reading and writing raw disk data. You ought to be able to load the cluster containing the directory entry for this file and just change the offending '?' character to something innocuous and write it back to disk.

It is my understanding that the Microsoft diskedit tool (not the Norton Utilities tool by the same name, which is only for FAT volumes) was last seen in Windows 2000 SP4. But there is a link to it that can be found here.

To locate the right cluster, you can download a trial version of DiskExplorer for NTFS.

You would start with File->Drive... to open the drive containing this bad file. Select Goto->Root Directory to get a directory view. Navigate to the directory containing your bad file by using the MFT# links. When you get there, the top of the window will say something like, "MFT# x12345 DIR: 'dirname', ...blah blah blah... starting at cluster x9302AE,... blah blah blah"

Now move over to Microsoft diskedit. First do File->Open... and specify Volume Name C: (if the file is on your C: drive). Leave the Volume File Name blank. Take that starting cluster number and enter it into diskedit under Read->NTFS Clusters...->Starting Cluster (enter it as a hex number).

Now use your arrow keys to scroll down to the bad filename. It's in unicode, so you'll be looking for something like "W.h.e.r.e. .H.a.v.e. .A.l.l. .t.h.e. .C.o.w.b.o.y.s. .G.o.n.e.?...o.g.g." Position your cursor over the bad "3F" character and type something safe, like 5F ('_'). Choose Write->It to write it back to disk.

There is another spot to hit (not sure if one or both are needed). Now, back in DiskExplorer, click on the Mft# for the bad file. You'll get a screen with a tree thing on the left that says "structures". Click on "Attributes" in the tree. It will show you a list of attributes, one of which will be something like $30 ... $FILE_NAME. So, $30 has the file name. Click on the Body node under the $30 node in the Structures tree. Select menu View->as Hex. Several lines down, you should see the filename again W.h.e.r.e. .H.a.v.e... etc. Over on the left side of the screen, you'll see the Sector column, which shows which disk sector you're looking at.

Back over the diskedit. Do Read->Sectors... and enter the sector number from DiskExplorer. As before, scroll down and replace the "3F" character with the same character as you did above. Choose Write->It to write it to disk.

I did all this, and the tools tell me that I've changed the character, but explorer doesn't. The directory must be cached somewhere. After a reboot, the change becomes visible.

share|improve this answer
add comment

have you tried:

type "Where*.ogg" > "Where.ogg"

might work.

share|improve this answer
show 1 more comment

This should work (at least, it did for me):

dir /X *cowboys*

That command would output somethig similar to this:

08/11/2011  15:21    <DIR>          WH5E97~1     Where Have All the Cowboys Gone
?.ogg

That WH5E97~1 is what you're looking for!
(Plase notice: such code is totally invented, but should be similar to the one you'll find)

Knowing that, a simple

rename WH5E97~1 "Where Have All the Cowboys Gone.ogg"

should do the trick.

Hope it helps.

share|improve this answer
show 1 more comment

The way i deleted the stubborn file was by opening 7zip, finding the file and renaming the file through 7zip. Mine was a song which had a space at the end of the file.

share|improve this answer
show 1 more comment

Try cygwin to rename the file:

the command would be: mv filename?.ogg filename.ogg

share|improve this answer
show 1 more comment

I've had exactly the same problem a year ago or so. Do a chkdsk and they'll be renamed!

share|improve this answer
add comment

Run Microsoft CHKDSK utility against the disk containing file with ? character. This character is not allowed in Windows and will be fixed automatically, then you'll be able to delete that file.

share|improve this answer
show 1 more comment

Most Microsoft internal commands are controlled with the presence of explorer.exe.

Open your Task Manager and examine the list of current active processes. You will find explorer.exe among them. Right-click and terminate/stop/close explorer.exe. Do not close the Task Manager yet. Now, go to the offensive file using a secondary file-manager and try deleting or renaming with wildcards. It will probably be successful.

Now, return to the Task Manager window and right-click top line saying Applications, then choose bottom button saying New Task. Enter explorer.exe. Explorer shows up again and the offensive file is no longer there.

share|improve this answer
add comment

The WinRAR GUI will allow you to rename the files without even having to pack them into an archive first. I've tested it in Windows 8.1, on a very long file name. Worked like a charm.

share|improve this answer
add comment

the only solution i found is a rather expensive one :(

MacNames features mapping of illegal characters ( /, \, , ?, *, etc.)

but with a price tag of $298 probably not worth it, just for 1 Paula Cole song :)

share|improve this answer
1  
interesting, but no I won't be buying this... Linux is still free :-) –  codeLes Aug 28 '09 at 23:55
add comment

I had the same problem. I could delete it using wildcards at command prompt

share|improve this answer
add comment

Use cmd.exe in this directory with wildcards. For example:

ren "Where Have All the *.ogg" "Where Have All the Cowboys Gone.ogg"
share|improve this answer
2  
@Hello71: Not in a DOS box, Linux boy. –  harrymc Mar 22 '11 at 21:47
show 1 more comment

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.