Jump to content

Long file paths... solutions?


Recommended Posts

Posted

While migrating our admin shared areas into a single shared drive I had a lightbulb moment and thought best to check the depth \ length of some of the folder and file names being used by staff... turns out I was in for a shock!

 

There's some huge names that are going over the (stupid and arcane) Windows file path limit of 255 characters, found them by using this rather nifty Powershell command...

 

cmd /c "dir \\?\E:\\ /s/b" | ? {$_.length -gt 254}

 

The only solution in the meantime is to take the output of said nifty command and get staff to rename the offending directories and files, although I can still open them in Windows as far as I can see so far...

 

I do love the post in this thread on Technet forums about it (search for "Why use one word where two will do" within the page!)

 

File name too long cannot copy

Posted

Thanks for the link, looks to be a nicer version of a similar tool I saw on Google trailing earlier on :)

 

Nice bit of tech background on why we've still got a 16-year old issue with Windows 7... some things never change!!!

 

Explorer still limited by MAX_PATH

 

Robocopy didn't seem to care about copying the files, everything went over OK but in the long run I've got to stop people being so verbose with folder names :p

  • Thanks 1
Posted

A good way of dealing with a single long path, without needing any extra tools, is to mount a directory somewhere along the path as a virtual drive with subst. This can the shorten the path below the limit.

For example:

subst X: C:\myreallylongpath\

del X:\therestofmyreallylongpath.txt

 

I think you can also use a special prefix "\\?\" on paths on the command line to get around the limit. For example:

del "\\?\C:\myreallylongpath\therestofmyreallylongpath.txt"

 

Bonus weirdness: a dot at the end of a file name will make it undeletable through explorer.

  • Thanks 1
  • 1 year later...
Posted
the best part is that the program's for free!

Though "use" does not include deleting or renaming files. You have to pay $69 for the full version to do that.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...