Link to home
Start Free TrialLog in
Avatar of anthonytr
anthonytrFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Max file length

I'm getting a little confused and finding it hard to get a definitive answer on the topic.

I'm trying to store files on a synology and Windows server (some finally find their way onto a USB thumb drive or CDRW/DVDRW disc) and sometimes the file names are not accepted as they are too long.  What is the max file name I can use when generating file names to save?

Thanks
Avatar of Kimputer
Kimputer

Keep it under 255 characters (works for Synology/Windows)! Then again, since you use it for a lot of things, including CD's, something might go wrong there (when burning the CD in UDF, the burn software might go for safety and truncate it to 128 characters).
If you try to keep it under 128 though, it should be the most compatible I'm guessing.
Max file name length is 255 but it's not advisable to go that long. When you start coping files with very long file names into folders, you can run into additional problems when backing up or restoring.


Here is some suppoorting info and links that should clarify the issue:

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)

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx

https://support.microsoft.com/en-us/kb/2891362

http://www.tomshardware.com/forum/30023-63-file-long

Hope this helps!
There are two components to be concerned with:

File name length: not to exceed 129 characters
Path length: not to exceed 260 characters.

So you may have a path such as C:\dir_1\sub_dir2\long_filename.ext
That total path can't exceed 260 characters and long_filename.ext can't exceed 129 characters.  Which in this case leave C:\dir_1\sub_dir2 to have a maximum length of 131 characters if long_filename.ext is 129 characters long.
In the root directory you might be able to have files with extremely long file names (the documentation isn't quite clear) but I wouldn't risk it.
Avatar of anthonytr

ASKER

Thanks for the comments on this.  

I have had a few files with names over 160 characters.  They seem OK in one server location and then have issues when moved.  Recently, one set of files were copied to a Synology NAS devices and have become stuck there as the file name is too long to open (I just get an error message) and too long to delete, again file name too long.

It all seems a little 'hit & miss' to me.
ASKER CERTIFIED SOLUTION
Avatar of dbrunton
dbrunton
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial