alexianit
asked on
Powershell, Path ... too long?
I have a script that I am running which is supposed to do just a simple copy of 2 folders from a system drive to an external USB HDD.
Script is attached.
This is the error I am getting and it seems to be halting the script after hitting this error a few times. It seems pretty pathetic that Microsoft would even allow you to create a path that would be too long for their own tool to handle. Am I doing something wrong?
Copy-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less
than 248 characters.
Script is attached.
This is the error I am getting and it seems to be halting the script after hitting this error a few times. It seems pretty pathetic that Microsoft would even allow you to create a path that would be too long for their own tool to handle. Am I doing something wrong?
Copy-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less
than 248 characters.
$SourceDir1 = "D:\Data\Users\*"
$SourceDir2 = "D:\Data\Sharing\*"
$Directory1 = New-Item -Name $((Get-Date).ToString('dd.MM.yyyy')) -Type Directory -Path "f:\Users\"
$Directory2 = New-Item -Name $((Get-Date).ToString('dd.MM.yyyy')) -Type Directory -Path "f:\Sharing\"
copy-item $SourceDir1 -destination $Directory1 -recurse
copy-item $SourceDir2 -destination $Directory2 -recurse
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.computing.net/answers/windows-31/how-to-copy-long-filenames-in-dos/9759.html
http://www.ztree.com/html/ztreewin.htm
http://www.computing.net/answers/dos/xcopy-with-long-filename/14069.html