Script copy: Long path names, add to archive

Hi,

We have a department of users being relocated to Germany.  I was a bit of a div and promised my counterpart in the German office that I would schedule an overnight copy of all the relocating department's files to a vm on our site he has remote access to, and archive all the data into a single zip.  The thinking was this would make the file copy over our WAN link faster.

I figured I could simply work out how to do this in PowerShell.  I got so far as to simply script the copying of the files but I ran into a problem with long filenames and paths.

The second problem is I have found population of archives whilst retaining file structure a bit challenging in PowerShell.

My issue is I only have till Monday 31 March to get this right.  So, I figured whilst I plug away at trying to figure this out perhaps someone on the Technet Forums might be able to lend a hand...?  I have seen reference to using Robocopy in "virtual mode" to get around this limitation.  I will start to give this a go, but if anyone has done this before and has a working sample script please do share.  Or even any pointers that might lead to a speedy solution are geatly appreciated.

Thanks in advance!!!


March 28th, 2014 3:06pm

Powershell, as installed, simply can't handle long filenames at this time. There are some 3-rd party modules that allow it, and you can always invoke/call a CMD as well. You can also set sub-directories as drive letter names and copy that way, Powershell doesn't care where the root is, only the total number of characters in the path name. 
Free Windows Admin Tool Kit Click here and download it now
March 28th, 2014 3:26pm

Working with long paths is challenging in the .NET Framework (and by extension, in PowerShell.) It typically involves dipping into the Win32 API, which supports long paths so long as they begin with a prefix of "\\?\". Having to take those files and add them to a zip adds a second level of complexity, and I'm not sure how difficult that will be.

In this case, your best bet might be to search for a command-line Win32 zip utility (not one based on .NET), and see if they get the job done for you, rather than trying to do it yourself through .NET.

March 28th, 2014 3:27pm

I've had just a situation like this and I used WinRAR.

Check how to use the rar.exe Cmd line tool and you'll kill two birds with one stone.


Free Windows Admin Tool Kit Click here and download it now
March 29th, 2014 12:04am

I've had just a situation like this and I used WinRAR.

Check how to use the rar.exe Cmd line tool and you'll kill two birds with one stone.


March 29th, 2014 12:04am

I'd like to recommand Robocopy. It covers long path, ACLs, Audit, and many others.

Please check the latest robocopy for your OS version. There are updates/hotfixes available.

e.g.: http://support.microsoft.com/kb/2639043/en-us

rgds,

Free Windows Admin Tool Kit Click here and download it now
March 31st, 2014 7:05am

Dear all,

Sorry for taking so long to get back to you - it has been manic.  Thank you so much for your swift replies.  Whilst I am sure that other solutions would work just fine, I found WinRAR the quickest and easiest as it did deal with both issues.

Cheers,

C

March 31st, 2014 11:35am

You are welcome,

glad I could help, 

Being a sysadmin is hard enough.

Free Windows Admin Tool Kit Click here and download it now
March 31st, 2014 1:47pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics