How to force Windows to rename a file with a special character?

86

26

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!

codeLes

Posted 2009-08-28T19:46:36.863

Reputation: 1 772

1I once had a flashdrive go bad, chkdsk moved the files to a different sector but kept the damaged names which contained fun characters such as CRLF or even backspace. :) – Nulano – 2017-02-09T15:59:17.137

1@IvanChau: Not a duplicate. That other question is about a space in the name, which is, in fact, a piece of cake, unlike this one here (with a wildcard). – Sz. – 2017-12-17T04:13:48.493

5May I ask how you got to this state? Windows generally won't let you do this. – Michael Kohne – 2009-08-28T19:55:09.793

and the answer is that I got the file from a Linux box. it's actually an .ogg file too. but I was wondering since I'm at work and haven't got my linux how to do it in windows... would be nice to know – codeLes – 2009-08-28T20:00:40.830

can you open cmd.exe and show the output of the command "dir" in this folder? it might help to see how windows sees the name... – Atmocreations – 2009-08-30T19:29:53.520

using dir shows the file with it's name as I have it listed in the question... – codeLes – 2009-09-02T15:30:30.520

6The filesystem NTFS allows some characters that Windows doesn't. If Windows meets such files, it b0rks. – Colonel Panic – 2012-08-18T00:25:27.583

Answers

42

Grab a linux live-cd and use that.

salmonmoose

Posted 2009-08-28T19:46:36.863

Reputation: 1 675

Do you need to restart the Windows? Or can you run both concurrently and still manage to successfully delete the file with special character? – Pacerier – 2017-03-11T11:07:14.430

1@Pacerier in theory, you possibly could, but it would mean you're mounting the drive in multiple operating systems concurrently, which is generally a bad idea. Shut down, and boot up in the new operating system. – salmonmoose – 2017-04-03T00:49:04.193

@Pacerier: should be possible (and even safe) to mount the problematic dir from a VM running on the same host OS. A random example: https://www.howtogeek.com/187703/how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox/

– Sz. – 2017-12-17T04:15:17.140

@Sz: That feels like you're expecting a lot from the Host OS - this would be relying on the VM to make calls to the host that the host may have problems with - it's this sort of behavior that leads to this sort of problem in the first place.

Unless you're suggesting mounting the partition and letting the client do the work this feels like not a great idea ^TM – salmonmoose – 2018-01-03T05:05:22.527

From home I use linux anyway... and the file is on a portable hard drive, I was just wondering if Windows could handle it... something like an <b>Sudo</b> windows command or something – codeLes – 2009-08-28T23:53:55.773

This is a wildcard issue, not a permission issue. Under linux just about everything is a valid character in a filename (including linebreaks) under Windows, there's a set of reserved characters, and no effective way to escape them. – salmonmoose – 2009-08-29T10:19:09.683

Make sure the live CD distro has reliable NTFS support. I am not sure how it is going now, but I do remember it being a bit buggy a while back. – Josh Hunt – 2009-08-30T11:58:53.860

3recent linux distros like ubuntu successfully support the most important features of NTFS. – Atmocreations – 2009-08-30T19:31:48.803

1Ubuntu 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 – 2009-09-02T16:59:23.023

Linux NTFS support is perfect. It's better than Windows, for example, Linux can delete files with : in the name. – Colonel Panic – 2012-08-18T00:26:00.413

29

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.

GAThrawn

Posted 2009-08-28T19:46:36.863

Reputation: 4 176

12Since 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 – 2009-08-28T22:18:43.203

You really should give this a try... Short filenames can sometimes be useful. – alex – 2009-08-29T10:38:49.207

4no short names, tried your example and also the dir/x proves that there aren't any listed. – codeLes – 2009-09-02T15:33:43.633

24

  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>

Aubrey Island

Posted 2009-08-28T19:46:36.863

Reputation: 1

Worked perfectly! This should be the answer. – enb081 – 2015-06-25T21:37:41.910

2@enb081 No, this shouldn't be the answer, since it doesn't have anything to do with the question, which was how to rename the files. Sheesh. – Jim Balter – 2017-02-19T03:32:29.413

You should advise that this will remove the files before showing the steps, or some unconcious user will delete them. A friend told me. – Juan C. Roldán – 2020-02-12T16:57:29.863

12

Try specifying the UNC path (see Naming Files, Paths, and Namespaces). 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.

Joshua

Posted 2009-08-28T19:46:36.863

Reputation: 4 434

This answer is definitely wrong. The restriction on valid characters is in the NTFS driver in the Windows kernel. \\?\ just bypasses file path processing in the user-mode runtime library. It doesn't allow opening filenames the contain the 5 wildcard characters ( *?"<> ), other reserved characters ( /|:\ ), or control characters. – Eryk Sun – 2016-12-25T23:11:21.760

It works in my case: I had a file name with Unicode character inside and with trailing \n. Don't ask me how do I created it (well, I'm trying to see if you can create multiple files with the identical name in Windows). Explorer, FreeCommander could not delete it but \\?\C:\... can. – Dio Phung – 2017-06-15T17:49:22.440

4gave 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 – 2009-09-02T15:37:24.453

12

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.

gohop

Posted 2009-08-28T19:46:36.863

Reputation: 1

This simple trick just helped me. I had resigned myself to losing the file after chkdsk did its work but this answer reminded me about \found.000. – davidbak – 2019-01-29T07:50:32.060

thank you. this is simple but effective way – علیرضا – 2019-08-09T03:48:37.083

11

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.

anon

Posted 2009-08-28T19:46:36.863

Reputation: 1

This works great. I tried several of the other options here, and this was the first one that worked. – rakensi – 2014-07-25T15:48:37.937

17zip was able to rename your file because filenames that end with spaces aren't a problem in Windows. Filenames containing '?' are a problem, and 7zip can't rename them. – Jim Balter – 2017-02-19T03:42:22.600

This worked perfectly for me, because my problem turned out not to be actual question marks, but weird Unicode characters that just displayed as question marks in my file manager. By importing the files (there were hundreds) into a 7-Zip archive and then exporting them again, 7-Zip simply converted the bad characters to underscores (_). Then I was able to work with the files again. Problem completely solved. Thanks for an excellent tip! – Jesper – 2017-05-12T00:37:06.983

I can't rename files with ":" character: https://i.imgur.com/dZBqqeP.png

– user598527 – 2017-05-20T12:16:30.257

7zip does work on files that end in a space, while windows explorer (and even a simple renamefile API call!) don't. – Marco van de Voort – 2018-05-19T12:39:22.053

You mean the file itself wasn't even in an archive, but you just used 7-Zip to rename it on the file system? Smart. – Arjan – 2014-01-12T10:44:30.250

8

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 "scan 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 ("recover") somewhere.

enter image description here

I have just done it (on Windows XP).

Jan Lachnitt

Posted 2009-08-28T19:46:36.863

Reputation: 1

Worked fine for a filename with an embedded /n which 7-zip couldn't manipulate. – davidbak – 2019-09-07T22:13:35.060

5

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.

braveterry

Posted 2009-08-28T19:46:36.863

Reputation: 783

I tried Flexible Renamer 8.4 which seems to do the trick. Sourced from the same website you mentioned. – JohnnyBizzle – 2014-11-29T10:41:44.287

I tried Directory Opus, and it didn't work (same error message). – user14068 – 2009-11-05T14:05:19.920

5

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.

user14068

Posted 2009-08-28T19:46:36.863

Reputation: 384

+1 for the correct (but more or less impractical) approach, hoping it'll bubble up a bit and overtake at least some of the wrong answers. ;) – Sz. – 2017-12-17T04:01:29.777

4

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"

Tom Kidd

Posted 2009-08-28T19:46:36.863

Reputation: 1 607

@Nicolas, you mean there was a ? or * or < or > or : in the name, and copy-ing just worked? (I just tried it and it didn't for me, unsurprisingly.) – Sz. – 2017-12-17T04:08:37.657

@Sz. sorry to heard it didn't work for you. I don't remember the filename I had to rename, but it worked for me with the copy command. Did you also try cygwin and the bash command mv? – Nicolas – 2017-12-20T09:44:38.020

1

@Nicolas, thanks for trying to help, but my point is that those chars I listed above (and a few others, like ", |, /, and of course the backslash (which I can't seem to enter here :) )) are in a different class of problematic chars (reserved), and I'm afraid, neither the copy command nor Cygwin can get round to renaming them. (You most likely had some different chars in your problematic filename.)

– Sz. – 2017-12-20T13:28:06.540

2tried, no luck. "The Filename, directory name, or volume label syntax is incorrect" – codeLes – 2009-08-28T19:51:51.610

It worked for me with the copy command. – Nicolas – 2013-05-06T07:10:14.547

4

  • 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.

Rangel

Posted 2009-08-28T19:46:36.863

Reputation: 1

Huh? How are you supposed to move that file (of OP) with the wildcard in its name? – Sz. – 2017-12-17T04:05:02.033

4

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.

ConceptJunkie

Posted 2009-08-28T19:46:36.863

Reputation: 1

This worked for me, or using the similar MSYS2 (a rewrite of MSYS, a fork of Cygwin) on Windows 8.1. I was able to mv the file to a new name and then delete it normally. My file had a space at the end, and it showed up using 'dir' - 'ls' didn't show it though. – Brian Burns – 2015-03-03T08:23:11.090

@bburns.km, at least you qualified your "works for me" statement. Of course it works for a filename with just a space at the end. \\?\ would also work in this case -- when used properly with a Unicode, fully-qualified path. It's bypassing the user-mode runtime library code that emulates some quirky old MS-DOS rule from the 80s that ignores spaces at the end of names. The problem with invalid and reserved characters can't be addressed like this. – Eryk Sun – 2016-12-25T23:24:09.220

I tried, cygwin wasn't able to delete the file ('No such file or directory'). Good idea though. – JulianHzg – 2014-03-01T13:54:21.997

3

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.

Michael Kohne

Posted 2009-08-28T19:46:36.863

Reputation: 3 808

I had a folder name with a : and doing this made the directory disappear. DON'T do this. – leeand00 – 2017-05-12T12:08:08.110

1

Actually, chkdsk moved the contents of the folder in the root directory of the hdd to a hidden folder and I was able to get my files back there see: https://superuser.com/a/320654/2293

– leeand00 – 2017-05-12T12:31:26.410

3

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.

unwiredbrain

Posted 2009-08-28T19:46:36.863

Reputation: 1

Not necessarily. According to the documentation typing dir t97* returns both files, because the asterisk wildcard matches the file t.txt2 to t97.txt by using its short name map T97B4~1.TXT

– unwiredbrain – 2014-08-18T12:08:48.090

Nice solution. Should work, but only works if the filename is longer than 8 characters (therefore not in my case). – JulianHzg – 2014-03-01T13:58:07.070

2

have you tried:

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

might work.

Atmocreations

Posted 2009-08-28T19:46:36.863

Reputation: 185

1The filename, directory name, or volume label syntax is incorrect. – Ciaran – 2009-08-28T23:23:37.767

1

I've also had a similar problem with a folder. The folder name was ".min." which is normally not allowed.

Rename Not Allowed (click for image)

Using Winrar I was able to solve this. What i did was

  • right click on the folder
  • select 'Add to archive...'
  • select a new archive name (one with no special characters)
  • from the archiving options select 'Delete files after archiving'
  • than select OK

Add To Archive... (click for image)

  • I then opened the .rar file
  • and renamed the file within

This is allowed since windows does not really check what is inside of the .rar file. As soon as you change the name then extract the file and you are done.

I hope this helps.

Lefteris Eleftheriou

Posted 2009-08-28T19:46:36.863

Reputation: 1

Doesn't work for me. My filename is 10:2. – Pacerier – 2017-03-11T11:12:04.733

1

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.

Michael Kohne

Posted 2009-08-28T19:46:36.863

Reputation: 3 808

Actually, in this case, it should already work with the filename as is since the question-mark is a wildcard. No need for the asterisk this time. – Synetech – 2013-08-20T14:53:15.863

1Sadly, that doesn't work, either with the original filename or with a more general wildcard like *.mp3. – JulianHzg – 2014-03-01T13:56:19.693

1

If you have WinRAR, pack it on WinRAR, rename it on WinRAR, unpack it.

Or you can try with a VBScript, 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"

Jhonny D. Cano -Leftware-

Posted 2009-08-28T19:46:36.863

Reputation: 754

2I 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 – 2009-08-28T19:58:31.473

tryijng your script nets me a "path not found" error (code: 800A004C). does it matter that this file is on an external USB drive? I put the file in the same folder... will try to hard code the entire file location next – codeLes – 2009-08-28T20:12:10.417

fully qualified name no work either... – codeLes – 2009-08-28T20:13:57.947

i agree up on the chkdsk option – Jhonny D. Cano -Leftware- – 2009-08-28T20:18:02.633

Tried it with WinRAR. Didn't work. Same result. – user14068 – 2009-11-05T14:12:22.437

1

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

ren *.* test.ogg

William Hilsum

Posted 2009-08-28T19:46:36.863

Reputation: 111 572

1dragging and dropping fails too with the same error... thanks though – codeLes – 2009-08-28T20:01:54.710

6Conversely you could try moving everything else out of the folder in question. – therefromhere – 2009-09-02T16:58:03.057

1

Try cygwin to rename the file:

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

Keck

Posted 2009-08-28T19:46:36.863

Reputation: 2 048

doesn't work, tried on Win7 64b – Max – 2015-01-19T19:33:49.513

i tried cygwin once on Vista, seemed to have the same issue, don't have access to it on my current work machine... – codeLes – 2009-09-02T17:11:49.300

1

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.

Chief Suspect

Posted 2009-08-28T19:46:36.863

Reputation: 1

1

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.

KellyRavenholm

Posted 2009-08-28T19:46:36.863

Reputation: 1

0

I had exactly the same problem with a file I had downloaded. I couldn't rename or move it, either in Explorer or the command line. However, what worked for me was to delete it in Explorer, and then restore it from the recycle bin. I can only assume this process "corrected" some of the invalid characters as I was then able to treat it like a normal file.

Steve Smith

Posted 2009-08-28T19:46:36.863

Reputation: 101

The filename is invalid or too long – user2284570 – 2017-03-09T04:25:30.777

0

Sorry kinda late, not sure how to remove the one file however you can all the files in the directory. Just create a Empty folder and then use robocopy to mirror that new empty folder over the top of the one with the bad file. This basically mirrors an empty list over the top of whatever was there.

mkdir Empty
robocopy Empty <badfiledir> /mir

JCollins

Posted 2009-08-28T19:46:36.863

Reputation: 1

0

I had a problem with a filename which had a trailing blank. Neighter Explorer nor cmd.exe move was able to rename (or delete) it.

I then used FAR Manager (far.exe in ConEmu). It is a console Norton Comander clone which works on 64-bit Windows 10.

With this I was easily able to see and change the trailing blank.

eckes

Posted 2009-08-28T19:46:36.863

Reputation: 918

0

The only thing that helped me was to download LockHunter

kill the processes from withing LockHunter, then renamed the folder, however LockHunter also does have option to rename folder.

Aleksandar Pavić

Posted 2009-08-28T19:46:36.863

Reputation: 319

0

OK, for me the thirdparty tool isobuster from smart projects worked well with a personal license. Just extract the folder/files to a windows ntfs drive and all non-windows characters are transformed to well formed windows folder and filenames. Ugh. :) Hope that helps! I will delete the non-conform folders next time I use my lubuntu system ;) - All that folks!

hemmlj67

Posted 2009-08-28T19:46:36.863

Reputation: 1

0

I was not able to make any of the suggested Windows utilities work for me to remove "?" and "*" characters from a filename.

I plugged the drive into a Raspberry Pi and changed the filenames.

YetAnotherRandomUser

Posted 2009-08-28T19:46:36.863

Reputation: 1 494

0

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

ren "Where Have All the *.ogg" "Where Have All the Cowboys Gone.ogg"

harrymc

Posted 2009-08-28T19:46:36.863

Reputation: 306 093

Globbing is done by the shell. – Hello71 – 2011-03-22T21:29:01.047

3@Hello71: Not in a DOS box, Linux boy. – harrymc – 2011-03-22T21:47:36.060

0

7-Zip file manager (7-zip.org) will rename files and directories that XP cannot. Just used it to extract a .tar file and rename the enclosed, illegally named .chm file. No LiveCD required.

Tschüß!

monsignormoney

Posted 2009-08-28T19:46:36.863

Reputation: 1

0

I had a similar problem with 2 nested folders with subfolders. I couldn't neither rename nor delete some of the files (I tried many ways). At last, I found the solution: Teracopy.

Install it, right click the folder or file and select teracopy. Teracopy will open, then just click delete or rename. It will rename or delete it.

You might want to give it a try.

Serkan Polat

Posted 2009-08-28T19:46:36.863

Reputation: 1

0

I've bumped into the same situation.

Googling around I learnt there is no native solution.

... and I use as a shell the JPSoft's TCC, which also could not handle those darned files.

But, I also learnt that Cedrick Collomb's Unlocker (http://www.emptyloop.com/unlocker/) is able to handle'm.

And I had it in my setup. Also, I highly recommend it.

Well, at least this solution does not involve leaving windows environment...

Marcus Vinicius Pompeu

Posted 2009-08-28T19:46:36.863

Reputation: 111

0

I fixed a FLAC file like this by using Winamp's basic open command, using that program explorer window. When I went to the folder, I had the rename option, unlike Explorer.

Freelance

Posted 2009-08-28T19:46:36.863

Reputation: 1

0

I came across a similar situation. None of the posted solutions worked for me but I finally found an easy solution:

  • No external tool needed
  • No knowledge of any programming or shell scripting language needed

I simply copied the file (yes, copying was still possible for me) to a USB stick, renamed it there and placed it back again! I leave it to others to explain why that worked.

David.

Posted 2009-08-28T19:46:36.863

Reputation: 1

0

This is not a direct answer (as in how can Windows rename a file) but this works for me. The illegal files are usually on an external drive so I connect the external drive to my Android tablet. This allows me to rename the file which can then be read by Windows. This deals with special chars but the usual problem I get is a file name starting or ending with a space or ending with a '.'

I tried one of the 3rd party tools FlexRenamer but this still struggles with the above.

JohnnyBizzle

Posted 2009-08-28T19:46:36.863

Reputation: 111

0

In most cases this answer is useless.
I got fooled by filenames with characters that are represented as question marks when in fact they're just characters the default M$-fonts won't/can't display.

Should I delete this post? It still might help some people...


Try using the cmd.exe built in tab-completion.

  1. dir /x does not help (the NTFS was created without support for short file names):

    dir
     Verzeichnis von C:\Temporal\_black
    05.10.2015  21:23    <DIR>          none\none         ? ?????????, ?????????
    
    dir /X
     Verzeichnis von C:\Temporal\_black
    05.10.2015  21:23    <DIR>                       none\none         ? ?????????, ?????????
    
  2. Trying to rename it by typing / copy'n'pasting the name does not work:

    C:\Temporal\_black> ren "? ?????????, ?????????" bart
    Syntaxfehler.
    
  3. To make it work you have to use tab-completion. Just navigate to the right directory in the cmd-shell, type ren, hit the tabulator-key and keep hitting it until the 'correct' name appears:

    C:\Temporal\_black>ren "? ?????????, ?????????"
    

    then type up the rest and hit enter:

    C:\Temporal\_black>ren "? ?????????, ?????????" bart
    

    You will be rewarded with this:

    C:\Temporal\_black> dir
     Verzeichnis von C:\Temporal\_black
    05.10.2015  21:23    <DIR>          none\none         bart
    

It's kinda tedious but so far this has always worked for me with files and directories (Windows 7 and 8).

Funny side note: The ren-commands in 2. and 3. are identical but it wont work without using tab-completion. And even if you've used tab-completion it wont work anymore as soon as you edit the name after the ren (e.g. remove and add a question mark).

Limer

Posted 2009-08-28T19:46:36.863

Reputation: 63