89

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
  • 1,832
  • 5
  • 23
  • 34
  • 5
    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
  • 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 Aug 28 '09 at 20:00
  • 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 Aug 30 '09 at 19:29
  • using dir shows the file with it's name as I have it listed in the question... – codeLes Sep 02 '09 at 15:30
  • 6
    The filesystem NTFS allows some characters that Windows doesn't. If Windows meets such files, it b0rks. – Colonel Panic Aug 18 '12 at 00:25
  • possible duplicate of [I named a folder the character for space, and now that I've switched over to Windows I need to rename it](http://superuser.com/questions/694881/i-named-a-folder-the-character-for-space-and-now-that-ive-switched-over-to-win) – Ivan Chau Jul 18 '14 at 07:58
  • 1
    I 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 Feb 09 '17 at 15:59
  • 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. Dec 17 '17 at 04:13
  • As windows in unable to resolve the path, have you tried renaming the file in Linux? I mean , renaming the file in Linux would ensure that it works in Windows too. – Lily AB Jun 26 '23 at 01:26

37 Answers37

43

Grab a linux live-cd and use that.

salmonmoose
  • 1,703
  • 12
  • 14
  • 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 Sudo windows command or something – codeLes Aug 28 '09 at 23:53
  • 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 Aug 29 '09 at 10:19
  • 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 Aug 30 '09 at 11:58
  • 4
    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 02 '09 at 16:59
  • Linux NTFS support is perfect. It's better than Windows, for example, Linux can delete files with `:` in the name. – Colonel Panic Aug 18 '12 at 00:26
  • **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 Mar 11 '17 at 11:07
  • 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 Apr 03 '17 at 00:49
  • @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. Dec 17 '17 at 04:15
  • @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 Jan 03 '18 at 05:05
  • You do not answer the question. Stack Exchange is not here for trolling ... – Luna Mar 16 '21 at 22:08
28

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
  • 4,326
  • 2
  • 22
  • 42
  • 13
    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
  • You really should give this a try... Short filenames can sometimes be useful. – alex Aug 29 '09 at 10:38
  • 4
    no short names, tried your example and also the dir/x proves that there aren't any listed. – codeLes Sep 02 '09 at 15:33
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>
SuperStormer
  • 137
  • 9
  • 1
    Worked perfectly! This should be the answer. – enb081 Jun 25 '15 at 21:37
  • 6
    @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 Feb 19 '17 at 03:32
  • You should advise that this will remove the files **before** showing the steps, or some unconcious user will delete them. A friend told me. – Carlos Roldán Feb 12 '20 at 16:57
14

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
  • 4,524
  • 24
  • 25
  • 4
    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 02 '09 at 15:37
  • 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 Dec 25 '16 at 23:11
  • 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 Jun 15 '17 at 17:49
  • I've used this way to rename files with extra spaces on the end of their names. The most common source, I've seen, of invalid file characters are from Macs using an SMB share. And from archive files (zip) created on a non windows platform. NTFS can support more characters than Windows can. So I'll have to disagree with Eryk, as the NTFS driver seems to allow these filenames to be created. – silicontrip Oct 31 '20 at 03:36
12

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
  • 1
  • 1
  • 2
  • 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 Jan 12 '14 at 10:44
  • This works great. I tried several of the other options here, and this was the first one that worked. – rakensi Jul 25 '14 at 15:48
  • 2
    7zip 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 Feb 19 '17 at 03:42
  • 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 May 12 '17 at 00:37
  • I can't rename files with ":" character: https://i.imgur.com/dZBqqeP.png – user198350 May 20 '17 at 12:16
  • 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 May 19 '18 at 12:39
11

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
  • 1
  • 1
  • 2
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).

user198350
  • 3,769
  • 15
  • 50
  • 89
Jan Lachnitt
  • 1
  • 1
  • 2
6

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
  • 384
  • 5
  • 10
  • +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. Dec 17 '17 at 04:01
5

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.

  • I tried, cygwin wasn't able to delete the file ('No such file or directory'). Good idea though. – JulianHzg Mar 01 '14 at 13:54
  • 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 Mar 03 '15 at 08:23
  • @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 Dec 25 '16 at 23:24
  • FWIW this is the only solution that worked (easily) for me. I don't have admin rights on this PC so installing anything or using anything requiring admin privileges was not possible and I needed to remove a leftover file named `con`. I had MSYS2 on my machine and I could simply `rm` it. – SolarBear Nov 20 '20 at 14:04
  • No, this does not work for file containing a `:` character. It says `mv: cannot stat 'Screenshot from 2015-10-11 21:29:26.png': No such file or directory` – Bastian Nov 22 '20 at 15:44
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
  • 1,627
  • 7
  • 24
  • 26
  • 2
    tried, no luck. "The Filename, directory name, or volume label syntax is incorrect" – codeLes Aug 28 '09 at 19:51
  • It worked for me with the `copy` command. – Nicolas May 06 '13 at 07:10
  • @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. Dec 17 '17 at 04:08
  • @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 Dec 20 '17 at 09:44
  • 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](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v%3Dvs.85%29.aspx#file_and_directory_names)), 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. Dec 20 '17 at 13:28
4

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.

Gaff
  • 18,569
  • 15
  • 57
  • 68
braveterry
  • 803
  • 14
  • 18
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.

slhck
  • 223,558
  • 70
  • 607
  • 592
Rangel
  • 1
  • 1
  • 1
  • 1
    Huh? How are you supposed to move that file (of OP) with the wildcard in its name? – Sz. Dec 17 '17 at 04:05
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
  • 3,968
  • 2
  • 22
  • 34
  • I had a folder name with a `:` and doing this made the directory disappear. DON'T do this. – leeand00 May 12 '17 at 12:08
  • 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 May 12 '17 at 12:31
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.

  • Nice solution. Should work, but only works if the filename is longer than 8 characters (therefore not in my case). – JulianHzg Mar 01 '14 at 13:58
  • Not necessarily. According to the [documentation](http://technet.microsoft.com/en-us/library/cc755121.aspx) _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 Aug 18 '14 at 12:08
2

have you tried:

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

might work.

studiohack
  • 13,468
  • 19
  • 88
  • 118
Atmocreations
  • 194
  • 1
  • 11
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.

1

Special characters don't work with ren; escape the problem character with move:

move "Where Have All the Cowboys Gone^?.ogg" "Where Have All the Cowboys Gone.ogg"

Tested in Win 10 with ? & %

Zimba
  • 1,051
  • 11
  • 15
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
  • 3,968
  • 2
  • 22
  • 34
  • 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 Aug 20 '13 at 14:53
  • 2
    Sadly, that doesn't work, either with the original filename or with a more general wildcard like *.mp3. – JulianHzg Mar 01 '14 at 13:56
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"
random
  • 14,638
  • 9
  • 54
  • 58
1

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

ren *.* test.ogg
William Hilsum
  • 116,650
  • 19
  • 182
  • 266
1

Try cygwin to rename the file:

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

Keck
  • 2,096
  • 1
  • 13
  • 16
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.

Doktoro Reichard
  • 5,390
  • 5
  • 35
  • 42
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.

Arjan
  • 30,974
  • 14
  • 75
  • 112
1

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
  • 111
  • 5
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
  • 101
  • 1
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
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
  • 1,208
  • 14
  • 20
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.

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
  • 1
  • 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
  • 1,919
  • 4
  • 24
  • 49
0

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

ren "Where Have All the *.ogg" "Where Have All the Cowboys Gone.ogg"
Gaff
  • 18,569
  • 15
  • 57
  • 68
harrymc
  • 455,459
  • 31
  • 526
  • 924
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üß!

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.

jaume
  • 5,487
  • 1
  • 26
  • 33
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...

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.

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.
  • 1
  • 2
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
  • 430
  • 3
  • 9