powershell - Copy file with relative path -


i copy files of type sub-directory relative path sub-directory directory relative path intact. e.g.:

source sub-dir:

c:\temp\sourcedirectory 

source files:

c:\temp\sourcedirectory\tonymontana\fileone.txt c:\temp\sourcedirectory\poker\filetwo.txt 

target dir:

c:\temp\targetdirectory 

desired result:

c:\temp\targetdirectory\tonymontana\fileone.txt c:\temp\targetdirectory\poker\filetwo.txt 

so far i've come with:

set-location $srcroot get-childitem -path $srcroot -filter $filepattern -recurse |     resolve-path -relative |     copy-item -destination {join-path $buildroot $_.fullname} 

however, "everything object" à la powershell beating me down (at least that's suspect). i.e. files gets copied, without relative path.

anyone enlighten me bit?

don't bother powershell cmdlets this, use robocopy:

robocopy c:\temp\sourcedirectory c:\temp\targetdirectory *.txt /s 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -