Copying files with very long filenames / paths

by Hanno 4. April 2011 21:41

I've never had a situation where I could not drag and drop in Windows when I wanted to copy some files from one location to another. Recently though, my perfect world was troubled when I ran into a problem with exceptionally long filenames (I refer to the total length of the file's location, i.e. c:\temp\dir1\dir2\dir3\dir4\dir5\file1.txt). Turns out that there is a limitation on the maximum length of the filename in the Windows API. You can find a very interesting post about it here.

To get around this I thought I'd use xcopy, which is included in most Windows releases. Whilst providing some neat advanced functionality, it did not solve the problem and I constantly got a "Insufficient Memory" exception. This basically just means that my path names were still too long.

So after some further consultation with Dr. Google©, I came accross an alternative from Microsoft©, namely Robocopy. Researching this utility revealed that it might solve my problem, but I wasn't sure, and skipped it in favor of a newer "better" utility from Microsoft.

Enter RichCopy, which as it turns out also doesn't solve my problem. RichCopy though, has an easy to use interface which basically utilises the robocopy library from Microsoft. 

I was able to find a workaround my problem, but it is not ideal at all, and will fail as soon as the path length increases again. 

Basically what I did was to create mapped drives to local folders using the UNC naming convention. I then proceeded to copy the files from one mapped drive to the next. I used the RichCopy GUI to copy files as it makes it quite easy to select specific folders and conditions for copying them.

Thanks to Joshua Hoffman and CS Truter.

EDIT: It turns out that Robocopy works like a charm! I also ran into some issues with RichCopy crashing for no apparent reason...

Tags: , , , ,

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading