Windows folder name characters

Support for Whitespace characters in File and Folder names for Windows

This article describes support for whitespace characters in file and folder names.

Original product version: В Windows 10 — all editions, Windows Server 2012 R2
Original KB number: В 2829981

Summary

File and Folder names that begin or end with the ASCII Space (0x20) will be saved without these characters. File and Folder names that end with the ASCII Period (0x2E) character will also be saved without this character. All other trailing or leading whitespace characters are retained.

  • If a file is saved as ‘ Foo.txt’, where the leading character(s) is an ASCII Space (0x20), it will be saved to the file system as ‘Foo.txt’.
  • If a file is saved as ‘Foo.txt ‘, where the trailing character(s) is an ASCII Space (0x20), it will be saved to the file system as ‘Foo.txt’.
  • If a file is saved as ‘.Foo.txt’, where the leading character(s) is an ASCII Period (0x2E), it will be saved to the file system as ‘.Foo.txt’.
  • If a file is saved as ‘Foo.txt.’, where the trailing character(s) is an ASCII Period (0x2E), it will be saved to the file system as ‘Foo.txt’.
  • If a file is saved as ‘ Foo.txt’, where the leading character(s) is an alternate whitespace character, such as the Ideographic Space (0x3000), it will be saved to the file system as ‘ Foo.txt ‘. The leading whitespace characters are not removed.
  • If a file is saved as ‘Foo.txt ‘, where the trailing character(s) is an alternate whitespace character, such as the Ideographic Space (0x3000), it will be saved to the file system as ‘Foo.txt ‘. The trailing whitespace characters are not removed.File and Folder names that begin or end with a whitespace character are enumerated differently by the Win32 and WinRT APIs due to ecosystem requirements.

More information

Whitespace Characters

There are various whitespace characters representing various ‘space’ widths (glyphs). Only the ASCII Space (0x20) and ASCII Period (0x24) characters are handled specially by the Object Manager. Although the Ideographic Space character (0x3000) is also generated by using the Spacebar (when IME is enabled), it is not handled specially.

  • 0x0020 SPACE
  • 0x00A0 NO-BREAK SPACE
  • 0x1680 OGHAM SPACE MARK
  • 0x180E MONGOLIAN VOWEL SEPARATOR
  • 0x2000 EN QUAD
  • 0x2001 EM QUAD
  • 0x2002 EN SPACE
  • 0x2003 EM SPACE
  • 0x2004 THREE-PER-EM SPACE
  • 0x2005 FOUR-PER-EM SPACE
  • 0x2006 SIX-PER-EM SPACE
  • 0x2007 FIGURE SPACE
  • 0x2008 PUNCTUATION SPACE
  • 0x2009 THIN SPACE
  • 0x200A HAIR SPACE
  • 0x200B ZERO WIDTH SPACE
  • 0x202F NARROW NO-BREAK SPACE
  • 0x205F MEDIUM MATHEMATICAL SPACE
  • 0x3000 IDEOGRAPHIC SPACE
  • 0xFEFF ZERO WIDTH NO-BREAK SPACE

Object Manager

ASCII Space (0x20) characters at the beginning or end of a file or folder name are removed by the Object Manager upon creation.

ASCII Period (0x2E) characters at the end of a file or folder name are removed by the Object Manager upon creation.

All other leading or trailing whitespace characters are retained by the Object Manager.

API Enumeration

Win32 API

The Win32 API (CreateFile, FindFirstFile, etc.) uses a direct method to enumerate the files and folders on a local or remote file system. All files and folders are discoverable regardless of the inclusion or location of whitespace characters.

Читайте также:  Что такое линукс linux

WinRT API

The WinRT API is designed to support multiple data providers (Physical Drives, OneDrive, Facebook, etc.). To achieve this, WinRT API uses a search engine to enumerate files and folders. Due to the search approach to enumeration, the WinRT API (StorageFile, StorageFolder, etc.) does not handle file and folder names with trailing whitespace characters other than ASCII Space (0x20) and ASCII Period (0x2E) residing on a local or remote file system. It does handle leading non-ASCII whitespace characters.

Observed Behavior

File Explorer and Desktop applications

All files and folders are visible within File Explorer and Desktop applications regardless of inclusion or location of whitespace characters.

Microsoft Store applications

When using the File Picker, files with a trailing non-ASCII whitespace character do not appear. The contents of subfolders with trailing non-ASCII whitespace characters are not displayed in the File Picker. Files or folders containing a leading non-ASCII whitespace character are displayed.

doctaphred / ntfs-filenames.txt

Information from https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file :
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:
(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.
— Do not use the following reserved names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8,
COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.
Also avoid these names followed immediately by an extension; for
example, NUL.txt is not recommended.
— Do not end a file or directory name with a space or a period. Although
the underlying file system may support such names, the Windows shell and
user interface does not. However, it is acceptable to specify a period
as the first character of a name. For example, «.temp».
Handy list to copy/paste:
<>:»/\|?*
Note: Other OSs and file systems may vary; but in general, the only forbidden characters
in filenames on Unix-like systems appear to be the forward slash (/) and the null byte.

This comment has been minimized.

Copy link Quote reply

sagi053 commented Mar 24, 2020

Nice regex to find and replace invalid chars in file name.
[<>:»/\|?*]
example:
javascript:
«my file is * invalid ?.pdf».replace(/[<>:»/\|?*]/g,»«);
php:
$fileName = preg_replace(‘/[<>:»/\|?*]/’,’
‘,’my file is * invalid ?.pdf’);
c#
var fileName = (new Regex(@»[<>:»»/\|?*]»)).Replace(«my file is * invalid ?.pdf»,»_»);

This comment has been minimized.

Copy link Quote reply

doctaphred commented Mar 25, 2020

Thanks for the contribution! Couple of notes:

\ is the escape character in most regex engines, so you’ll need to repeat it to make sure it gets included in the character class and doesn’t just escape the | after it: [<>:»/\\|?*] / «my file is \\ invalid ?.pdf».replace(/[<>:»/\\|?*]/g, «_»);

Also, I’m not super confident in my PHP knowledge, but I think you’ll need to double-escape the backslash: once because PHP treats it as an escape character in the string literal (even when using single quotes), and a second time for the regex engine. So I think you’ll need a total of four \ characters: ‘/[<>:»/\\\\|?*]/’ (gross).

Читайте также:  Готовый веб сервер для windows

(It looks like C# uses the @ prefix to denote verbatim strings, which look like Python’s raw strings, and should only need a single escape for the regex engine. JS does not (yet) seem to offer unescaped string literals, but RegExp literals don’t apply the additional layer of escaping.)

How to change a user’s folder name in Windows 10 build 1803

I am running Windows 10 build 1803 and I have noticed over the weekend that my user folder name is complete.

How can I rename my folder name to my complete name?

When I first login, my full name is shown.

Replies (8) 

Hi Jack. I’m Greg, an installation specialist and 8 year Windows MVP, here to help you.

See this tutorial to change Account Name if it’s a Microsoft or a Local Account:
http://www.thewindowsclub.com/change-account-us.

I hope this helps. Feel free to ask back any questions and let us know how it goes. I will keep working with you until it’s resolved.

Over 100,000 helped in forums for 11 years. I don’t quit for those who are polite and cooperative.

Windows MVP 2010-21

Was this reply helpful?

Sorry this didn’t help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Step 1: log into the local Administrator Account:

Open Start
Type: cmd
Right click CMD
Click Run as administrator

At the command prompt, type:
net user administrator/active:yes

Close command prompt, restart, then try signing into the Administrator account.

Open Start
Type: cmd
Right click CMD
Click Run as administrator

At the command prompt, type:

wmic user account list full then hit Enter. Scroll down then take note of the SID values for the account you want to change.

Type: cls to clear the screen. The next step is to rename the account. Doing this from the command line is just as easy.

Type CD c:\users then hit Enter.
Type: rename OldAccountName NewAccountName

For example, rename “Jack TheRipper” “Jack Ruby”

Open Start, type: regedit

Click Run as administrator.

Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

Remember that SID value we accessed earlier? Now is the time to reference it.

Once you find it, select it, then double-click the value ProfileImagePath. You will see the old name we had earlier is still there. Change it to the new name you want to use.

Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.

3 people found this reply helpful

Was this reply helpful?

Sorry this didn’t help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I went to that link and my name shown there is ok, it is my folder name (c:\users\username) that isn’t complete, it only shows part of my name and not my complete name.

Читайте также:  Windows key password crack

Was this reply helpful?

Sorry this didn’t help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

That is one hell of a mouthful of commands that you lost me

Microsoft should have made it easy to change your c:\users\username

I guess I’ll just stick with my shortened name until I decide to do a clean install.

What if I went through the registry and changed all instances of my shortened name to my full name?

Was this reply helpful?

Sorry this didn’t help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Trust me, I find it convoluted myself.

Could you please file a bug report and send me the short link so I can bring it to the attention of the Windows Engineers?

Press Windows key + F
This will open the Feedback hub
Proceed to submit your report.

You can reach out to key folks on the Windows Engineering team through Twitter

Make sure you send short link to them. They are known to be very responsive and might be able to point it in the right direction.

Was this reply helpful?

Sorry this didn’t help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I think what you’re referring to is when you install Windows with a MS Account and it cannot connect to the account to import your full name, it truncates the email address and uses the first five letters. This is annoying to many including myself, so I filed it as a bug to be fixed a few years ago and finally got an answer back that they intend to leave it that way.

The solution is that when you install WIndows to always set up a Local Account first, then when you get into Windows you can change it to a MS Account: https://www.tenforums.com/tutorials/5375-switch.

For now until you reinstall one other thing you can do is to create a new Local Admin account http://www.howtogeek.com/226540/how-to-create-a. , change your Microsoft account to a Local Account to release it following http://www.zdnet.com/article/windows-10-tip-swi. then restart into the new Local Account to associate your MS Account with it.

Since this is clearly not satisfactory If you want to express your opinion on this to Microsoft use the Feedback Hub app in Start Menu where developers are tasked to process consumer feedback. They will not even see it here. This is a tech forums staffed mostly by volunteers trying to help others with your problems.

You can post back here the Feedback Share link others can vote it up and add to it, and I’ll try to vote it up with my MVP badge FWIW.

I hope this helps. Feel free to ask back any questions and let us know how it goes. I will keep working with you until it’s resolved.

Over 100,000 helped in forums for 11 years. I don’t quit for those who are polite and cooperative.

Оцените статью