How to do powershell move all the subcontent of folder to dst in recursive mode
Posted on 2014-12-26
Hello, World :)
I looked through the help for: copy-item, move-item, get-childitem before writing this question.
I need to move all the content (except x:\tmp itself) to the new destination, so i'd get in result:
The reason why i don't need to move "x:\tmp" itself - there are too many specific NTFS permissions of that folder so, as i need to do movement every night, I don't wanna recreate x:\temp each time and set the same permissions again.
PS X:\> get-childitem -path x:\tmp\ -recurse -force | move-item -destination x:\dst -force
Get-ChildItem : Could not find a part of the path 'X:\tmp\1'.
At line:1 char:14
+ get-childitem <<<< -path x:\tmp\ -recurse -force | move-item -destination x:\dst -force
+ CategoryInfo : ReadError: (X:\tmp\1:String) [Get-ChildItem], DirectoryNotFoundException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
I still cant understand why this command generates errors, EVEN it works, BUT i don't wanna use this command: AS IT GENERATES ERRORS (yes, in this was i'm a perfectionist: everything works fine ONLY if it doesn't produce any errors).
Also, robocopy works fine:
robocopy $srcpath $dstpath /E /R:1 /W:10 /NP /MT:2 /ETA /TEE
But, as i'm using PSh instead of batch, and in my opinion everything that is possible for PSh must be used.