Reputation: 13
I am trying to copy files from mapped network drive.Some of them gets copied but others are not copied as filename has got some wierd characters.
for example my mapped network drive Z: contains the following files:
I am able to copy first two files from mapped network drive but not the last one using the below command
Copy-Item -LiteralPath Z:\$name -Destination I:\Dat\SomePath\ss/ -Force
The error which I get is:
Copy-Item : Could not find file 'Z:\k�rekort terje(3).pdf
I tried [WildcardPattern]::Escape($name) but that also did not work Kindly help if anybody knows the solution
Upvotes: 0
Views: 823
Reputation: 161
Maybe you could use robocopy.exe oder xcopy.exe instead?
Maybe old "dir /x" can help to find out the old "8.3" filename (like "GET-GP~1.PS1" for "Get-GPProcessingTime.ps1") and this can be used to copy or rename the file?
I also remember something about bypassing file system logic using unc-like syntax like \\0\driveletter\directory or whatever - unfortunately I don't remember the exact syntax. Maybe someone else does?
Upvotes: 1
Reputation: 669
Try something like this:
$files = Get-ChildItem -Path "Z:\"
$files | % { Copy-Item -Destination "I:\Dat\SomePath\ss" }
Upvotes: 0