1) Windows删除文件名中所有的非法字符和空格,非法的字符包括. " / \ [ ] : ; = , 2) 短文件名仅可包含一个句号(.),如果采用了最后的句号之后文件名合法并且没有空格,然后Windows会从文件名中移除其它句号。例如,Windows生成短文件名Thisis~1.txt从长文件名This is a really long filename.123.456.789.txt
另外,Windows会忽略最后的句号(译者注:句号后面无其它字符)并使用前面一个句号。例如,Windows生成短文件名Thisis~1.789从长文件名This is a really long filename.123.456.789. 3) Windows截取文件名,如果必要的话,到6个字符并且添加一个波浪符()和一个数字。例如,每一个唯一的文件名需要以”1.”为结尾被生成。如果多个文件名以”2,”,”3,”结尾,以此类推 4) Windows截取文件的后缀名到3个字符或更少 5) Windows翻译文件名中所有的字符为大写
需要注意的是,尽管一个目录或文件名包含一个空格,但是小于8个字符,Windows仍然会生成一个短文件名。这种行为也许导致一些问题如果你尝试访问网络上的文件或目录。为了解决这种情况,替换成一个合法的字符例如下划线(_)。这样的话,Windows不会生成一个不同的短文件名。 例如,”Afile1.doc”从”A file.doc”中生成,因为长文件名包含一个空格。不会从”A_file.doc”中生成一个短文件名因为文件名短于8个字符并且没有包含空格。 短文件名”Alongf1.txt”从长文件名 “A long filename.txt”中生成,因为长文件名超过8个字符。
---Summary--- Windows supports long file names up to 255 characters in length. Windows also generates an MS-DOS-compatible (short) file name in 8.3 format to allow MS-DOS-based or 16-bit Windows-based programs to access the files.
---More Information---
Windows generates short file names from long file names in the following manner:
Windows deletes any invalid characters and spaces from the file name. Invalid characters include:
. " / \ [ ] : ; = , Because short file names can contain only one period (.), Windows removes additional periods from the file name if valid, non-space characters follow the final period in the file name. For example, Windows generates the short file name Thisis~1.txt from the long file name This is a really long filename.123.456.789.txt Otherwise, Windows ignores the final period and uses the next to the last period. For example, Windows generates the short file name Thisis~1.789 from the long file name This is a really long filename.123.456.789. Windows truncates the file name, if necessary, to six characters and appends a tilde (~) and a digit. For example, each unique file name created ends with "~1." Duplicate file names end with "~2," "~3," and so on. Windows truncates the file name extension to three characters or less. Windows translates all characters in the file name and extension to uppercase. Note that if a folder or file name contains a space, but less than eight characters, Windows still creates a short file name. This behavior may cause problems if you attempt to access such a file or folder over a network. To work around this situation, substitute a valid character, such as an underscore (_), for the space. If you do so, Windows does not create a different short file name
For example, "Afile~1.doc" is generated from "A file.doc" because the long file name contains a space.
No short file name is generated from "A_file.doc" because the file name contains less than eight characters and does not contain a space.
The short file name "Alongf~1.txt" is generated from the long file name "A long filename.txt" because the long file name contains more than eight characters.