can't copy folders & Files with long names

I have a shared lun that is accessible to users, each user is mapping it on their Windows 7 Pro X64 machine and adding their projects to it on daily bases

I am running into problems when I am trying to archive some of the folders into a server 2008 R2 Raid drive. The error is about the file name is too long and can't be copied.
The users are using description in the file/ folder name so they can search it faster in the future and for me to shorten the name is not always easy as they use detailed description.

Educating the users won't help me. How can I stop users from creating long folder or file names? If the file name is too long, then Windows should have stopped them in the first place, Why does Windows complains only when I copy them?

What other IT guys are doing to fix this issues?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How long is the path the file is being copied to ?

File name + path here might be what is blocking you.

Try simply moving the files to the root of the folder / or map a drive as the destination path / or simplify the destination folder to have the least number of characters possible.

Windows does have a 255 character limit if memory serves correctly.

You can probably write a quick script to rename files longer than 250 characters to drop enough characters to be 240 and then do your backup.
Aaron TomoskySD-WAN SimplifiedCommented:
It's a really annoying problem with windows. If the structure permits, you can map a drive deep in the folder structure to shorten the overall length. Also I believe that robocopy functions well with the long path when other programs fail. Personally I've used rsync to backup some ridiculously deep file structures and never had a problem. Can you mount the lun on a linux/unix system? I've never tried this route, but a windows rsync client might also function well
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

smaguireAuthor Commented:
our users have a very complicated folder structure and they use description in their folder & file naming so it's easy for them to find a particular file(s) or folder(s) by searching from within windows explorer search box, so renaming them is out of the question.
let us say, If they map my lun on their drive as drive F:\Engineering\
and inside that engineering folder: project1, project2, ...etc. (a project folder can be as big as 20 GB!! their engineering software use a lot simulation objects, movies, pictures,..etc and their objects gets saved by the software with a very long name)

when I am trying to copy everything in dirve F:\ into another drive on another server let us say: E:\Archived\

I think this is my problem but don't have a clear idea on how to approach it. If the user have already created a 255 character long on their drive F:\ , coping it over to drive E:\Archived\ , would complain because 255 characters + the length of "Archived\" would be more than the allowable 255?

and the problem is not by removing the "Archived" folder either, because some users would map their drive two or three level deeper into the folder structure.

I am looking for a solution that would prevent the user from creating long files rather then renaming it myself after they are being created.
The easiest solution is just to tell them not to.

Your problem here is not just the long files names but the paths you need to use for your archiving.

To be frank, if the names allow them to search I cannot see how trimming the last 10 characters could have an impact (yes they may find multiple files with similar names but I am guessing time stamps would fix that)

Simply let your users know that files names longer than (x) will be trimmed as a part of the archival process and them simply perform that step when copying - File name length (minus) path length equal the new length of the name.
smaguireAuthor Commented:
Its like telling your kids not to eat candies, it will not work for a long term.

I can't trim because sometimes the last 10 characters are files like this: 1234567.doc or .pdf or...etc so a whole file will be removed!

I will try mapping a drive two level deeper into the structure and see if I can copy then...
No we can set the trim to not move files with names shorter than ten.

The idea will be we do a simple script

if the length of the file name + the length of the destination is  longer than 255 then trim, else just copy.
smaguireAuthor Commented:
What I don't understand is how could they have created it in the first place and violated Windows 255 naming limit? I mean I also tried to duplicate one of the projects that is giving me grief in the original drive and it complained about some folders are too long to be copied.

Is there a free software that would scan a folder and let you rename the invalid ones to any name or to a specific name that you guys are aware of?

I don't think they actually have files named longer than the limit, I think as indicated above when you try to copy the new name + destination path included is longer than windows allows.

Here is a piece of software:

Nobius also has a good recommendation:

I am sure there are many others.

You can also probably write a script of your own to do this if you wanted to (or ask a question on here and have one of the experts do it for you).
Thomas RushCommented:
Think of the name length problem like a power strip with six outlets.  The circuit and power strip are rated for 20 Amps, and no single device you plug into it will be more than 15 Amps -- but you can sure as heck plug six 10-Amp devices into the strip and overload it.  Likewise, there's an overall "path length limit" in Windows, and there's also a limit for length of an individual file or directory.  Similar to the power strip example, when you add up the length of the file name and the length of the directory names, you can exceed the path length limit.  Can you make the full path on the network share shorter?

Perhaps your best solution -- other than shortening path names, if possible -- is to run a script before you do the backup, and let the script shorten the file names in the directory *only if needed*... then back the files up.  Note: The file name shortening is not, perhaps, as simple as it might seem at first glance; you'll be tempted to whack the last ten (or whatever) characters off... but what if that would give you two files with the same name?  You've got to make sure there's error checking, and an alternate scheme that will ensure that you don't end up with file names still too long, etc.
smaguireAuthor Commented:
That's what I thought but after more testing it still doesn't make sense:
this is what I have:

I am trying to copy it to:

to the root folder, and still complains about the file is too long to copy to the destination? how is this possible?

That software is for commercial use.
Give this one a go as well it might work well for you.
Thomas RushCommented:
You see the target directory as F:\ -- but how does Windows represent that internally?  It's very likely stored as something like \\servername\directory -- in which case, the length of your server name could be tipping the scales.  I haven't been able to find a definitive answer in a quick search, and it probably doesn't matter; the main thing is that it's not working, and the second thing is to get you working.  Worrying about why it's not working should be much further down on the list.
did you try the software i posted?
also post an example of the complete file long path
often you can rename it easily to shorten up
C:\Users\username\Documents\WinMail\Local Folders\Geïmporteer 8b7\Herstelde b  29\11-05-2010  823\Local Folders\Herstelde b  29\11-05-2010  823\Local Folde 8be\Sent Items
can be renamed to
C:\Users\username\Documents\WinMail\Local Folders\renamed\Sent Items
smaguireAuthor Commented:

you are right but regardless of how Windows is looking into the F:\ drive. The projects with long names are sitting in the same drive and if it was created in F:\Archived\Project1 then I *Should* be able to copy it to a shorter path (to the root) within the same drive F:\
smaguireAuthor Commented:

not yet as doesn't work and I have download some frameworks to get it installed. I might have to wait until after hours in case the frameworks installation would want to reboot the server.

I am talking about hundreds if not thousands of nested folders and files, it would take for ever to shorten them manually
I still think a quick powershell script would be best in this instance where you have control and can do multiple renames on the fly etc.

If you want to go that path, let us know.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smaguireAuthor Commented:
nobus, I tried the software, it says "Please buy full version to perform operation
smaguireAuthor Commented:
it might be the only solution for now...
smaguireAuthor Commented:
Awarded points for participation, I will be posting another question for writing script on how shorten long file names and folder

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Network Management

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.