How to create folder name or file name with special characters like \ / : * ? " < > |

This is very important for me, naming of file/folder which contain these characters.

It may be important to you, but you will have to let this go and find a different way to solve your problem.

These characters are not allowed by the Windows OS function calls that handle filenames.

They are specifically not allowed because they have another use:

  • \ - Reserved for use as a path separator and escape character
  • / - Reserved for use as a path separator
  • : - Reserved for use as a drive name delimiter
  • * and ? - Reserved for use as wildcard characters
  • " - Reserved for use to quote names containing spaces
  • <, > and | - Reserved for use as command redirection operators

You can, of course, create files with names containing these characters using a different operating system (as long as that operating system can read/write a Windows file system).

However, you will be unable do do anything with those files using any Windows programs and they will not understand the file names and will generate errors.


Naming Files, Paths, and Namespaces

Naming Conventions

The following fundamental rules enable applications to create and process valid names for files and directories, regardless of the file system:

...

Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:

  • The following reserved characters:

    < (less than)
    > (greater than)
    : (colon)
    " (double quote)
    / (forward slash)
    \ (backslash)
    | (vertical bar or pipe)
    ? (question mark)
    * (asterisk)
    
  • Integer value zero, sometimes referred to as the ASCII NUL character.
  • Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.
  • Any other character that the target file system does not allow.

Source Naming Files, Paths, and Namespaces


But I really want to do this anyway.

Install cygwin and use touch.

I haven't tested all the possibilities but the following work:

touch :
touch \|
touch \"
touch \>

Example output:

DavidPostill@Hal /f/test/impossible
$ ll
total 0
-rw-rw-rw-+ 1 DavidPostill None 0 Aug 10 21:03 '"'
-rw-rw-rw-+ 1 DavidPostill None 0 Aug 10 21:02 :
-rw-rw-rw-+ 1 DavidPostill None 0 Aug 10 21:02 '|'
-rw-rw-rw-+ 1 DavidPostill None 0 Aug 10 21:07 '>'

As you can see they are not usable in Windows:

F:\test\impossible>dir
 Volume in drive F is Expansion
 Volume Serial Number is 3656-BB63

 Directory of F:\test\impossible

10/08/2016  21:07    <DIR>          .
10/08/2016  21:07    <DIR>          ..
10/08/2016  21:03                 0 
10/08/2016  21:02                 0 
10/08/2016  21:07                 0 
10/08/2016  21:02                 0 
               4 File(s)              0 bytes
               2 Dir(s)  1,772,601,536,512 bytes free

enter image description here


In Windows, you cannot create files with those characters. There's no solution, these characters are prohibited by the Win32 API.

Win32 is a subset of the POSIX namespace and is case insensitive. It uses all the Unicode characters, except: '"' '*' '/' ':' '<' '>' '?' '\' '|' N.B. Names cannot end with Dot '.', or Space ''.

-- http://dubeyko.com/development/FileSystems/NTFS/ntfsdoc.pdf


Build your own font set. Replace some of the characters you do not use with the images of the reserved characters.