Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - recursive filterd copy

Reply
 
Old 01-22-2008   #1 (permalink)
Manage SQL servers using PowerShell?


 
 

recursive filterd copy

How would I copy all files of a certain type (e.g. *.dll and *.pdb) in a
certain directory recursively (i.e. including all subdirectories) to another
directoy recursively (i.e. keep the subdirectories).

My System SpecsSystem Spec
Old 01-23-2008   #2 (permalink)
Gerd Schneider


 
 

RE: recursive filterd copy

Existing stand-alone console applications still work well with PS, so
robocopy.exe could be the tool of choice for this task:

robocopy <sourcefolder> <destinationfolder> *.dll *.pdb /s

----
Gerd


"Manage SQL servers using PowerShell?" wrote:
Quote:

> How would I copy all files of a certain type (e.g. *.dll and *.pdb) in a
> certain directory recursively (i.e. including all subdirectories) to another
> directoy recursively (i.e. keep the subdirectories).
My System SpecsSystem Spec
Old 01-23-2008   #3 (permalink)
Shay Levi


 
 

Re: recursive filterd copy




$source="C:\temp"
$destination="D:\copyTest"

get-childitem -recurse -path $source -include *.dll,*.pdb | foreach {
$dir = $destination + (split-path $_.DirectoryName -NoQualifier)
New-Item $dir -itemtype directory -force
copy-item $_-destination $dir
}




-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> How would I copy all files of a certain type (e.g. *.dll and *.pdb) in
> a certain directory recursively (i.e. including all subdirectories) to
> another directoy recursively (i.e. keep the subdirectories).
>

My System SpecsSystem Spec
Old 01-23-2008   #4 (permalink)
Kiron


 
 

Re: recursive filterd copy

$src = 'C:\SourceDir'
$dest = 'C:\DestinationDir'
$fTypes = '*.dll', '*.pdb'
ls $src -i $fTypes -r | % {
$file = $_.fullname
$new = $file -replace [regex]::escape($src), $dest
trap [System.IO.DirectoryNotFoundException] {
[void](md $(split-path $new -par))
cpi $file $new
continue
}
cpi $file $new
}

--
Kiron
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
recursive directory search VB Script
Workaround to MS recursive paremeter bug PowerShell
Recursive delete slow PowerShell
Recursive directory size in O(1) Vista file management
Recursive directory size in O(1) Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46