Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I run Microsoft windows on a few of my machines. I don't know if many people know about this issue in the OS but you can't have very long filenames, from what I know Linux can have longer names, I have never run into this issue on my Linux machines.

Anyway I run into issues whenever copying folders & files to backup drives. I manually backup of my data, finding and changing names of files, this is very very tedious.

Is there a software tool to shorten folders or filenames that are found to be to long on Windows?

I have drive image duplication software which does the job but in a way that I don't like, plus moving files can become a hassle at times if the names are too long to copy.

share|improve this question

4 Answers 4

up vote 3 down vote accepted

Often you can zip the files into an archive to get around the length limitation when moving deep / long name file structures from one machine to another.

share|improve this answer
    
It is about 1 gig so zipping would be very slow, though it is an option. –  Daniel May 30 '09 at 5:49
3  
@daniel Zip has a 'store' option that doesn't do compression, which would make it faster. Also, tar has been ported to windows (variously). –  sysadmin1138 May 30 '09 at 5:52
    
+1 for tar. . –  nedm May 30 '09 at 6:46

As mentioned previously, putting together a zip file is an option.

Another option may be to create a script that uses only the windows short names for the destination. This has the disadvantage of permanently renaming all of your files unless you come up with a way to keep track the old and new file names. I was just playing with some VBScript at work today that'd do just this.

A more costly solution may be to create a mirror setup with a second hard drive.

share|improve this answer

See http://www.ratsauce.co.uk/notablog/longfilenames.asp

If you use a full path, i.e. starting with the drive letter, and prefix the filename with \\?\ you can get around the 260 character length limit.

JR

share|improve this answer

Just mentioning a trick I do not see mentioned here yet.

Take this file for example:

C:\Folder1\Really Long Path\Such Recursion\So Deep\Wow\Still Going\I will run out of ideas soon\I have organizational problems\Obsessive compulsive subdirectory disorder\Here is a guid for no good reason\936DA01F-9ABD-4d9d-80C7-02AF85C822A8\Almost there\Tax Returns\2013\2013_tax_return.pdf

This full file path is 290 characters long. The shell (Windows Explorer) and most command line utilities probably won't let you touch it.

Use the subst command like so:

subst X: "C:\Folder1\Really Long Path\Such Recursion\So Deep\Wow"

Now you can access (and delete, move, etc.) the file thusly:

X:\Still Going\I will run out of ideas soon\I have organizational problems\Obsessive compulsive subdirectory disorder\Here is a guid for no good reason\936DA01F-9ABD-4d9d-80C7-02AF85C822A8\Almost there\Tax Returns\2013\2013_tax_return.pdf

And now that file name is only ~235 characters or so, so you will not encounter the "Filename is too long" problems any more.

In the Windows API, there is an infamous constant known as MAX_PATH. MAX_PATH is 260 characters. The NTFS file system actually supports file paths of up to 32,767 characters. And you can still use 32,767 character long path names by accessing the Unicode (or "wide") versions of the Windows API functions, and also by prefixing the path with \\?\.

MAX_PATH was set in stone a very long time ago in the Windows world. I think it has something to do with ANSI standards at the time... but it's one of those things that's very difficult for Microsoft to change now, as now we have thousands of programs and applications, including some written by Microsoft themselves, that use MAX_PATH and would fail in strange new ways if the constant were suddenly changed. (Buffer overflows, heap corruption, etc.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.