21

I've used a live boot CD of Linux couple weeks ago and have redirected screenshots to my NTFS drive.
The filenames contain a colon symbol : which is one of the unsupported characters for a filename on the NTFS file system.

Unsupported characters are: \ / : * ? " < > |


I tried to solve this using the regular Command Prompt, PowerShell, some scripting languages, and even Bash on Windows but none worked.

I even tried the \\?\ path trick but it doesn't work either.

The limitation is obviously tied to the NTFS file system, so what's the way to continue from here?

3 Answers3

40

Boot back into your linux live cd and correct it from there.

Windows just can't handle this. This needs to be done from linux.

LPChip
  • 66,193
16

@LPChip's answer is the answer that solves your problem, but I have more details that I think warrants another answer here.


Filesystems are data structures that manage your files on a disk, so normally FS themselves have minimal restrictions on file names - most modern FS (NTFS included) can even technically hold null bytes just like how Python holds strings (length + array of bytes).

That FS supports arbitrary strings does not mean you should. Practical operating systems impose restrictions on file names so that they can present a sensible "path" interface to the upper level, where applications can access files.

This is the reason every OS has some limitations on file names. Notably, Linux and other Unix systems allows all characters except the null byte and the path separator (forward slash) in file names, excluding two reserved names . and .. (current directory & parent directory). Windows, for historic reasons, reserves more characters and more special names (e.g. CON, LPT, COM1 to COM9 etc.) through normal Windows API, but still allows these names via a low-level API as used by WSL1. For example, you can create something like /mnt/c/CON in WSL1 and use it normally, but you can't do anything with it outside WSL environment.

On Linux, fsck programs can rewrite invalid file names if they somehow end up in the filesystem. I suppose chkdsk.exe can do something similar but I have not verified that.

iBug
  • 11,645
2

Wikipedia's sidebar claim about the disallowed characters cites a document (not official, it seems). There is a web-page-ified version here.

Digging into it, we see in section 13, "Concept - Filename Namespace", that there are multiple allowable character sets. Windows doesn't play nice with the POSIX one, it seems.

However, the mention of the DOS type (the old "8.3" style) brings to mind Windows' ability to deal with the so-called "short names" if all else fails. You should be able to use a cmd prompt to do dir /x to see the short name corresponding to the file's forbidden "long name". It may be possible to use that "short name" to rename the file to something with fewer problems.

Please let us know how it went!

Atario
  • 1,266
  • 3
  • 11
  • 19