Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Duplicating Directory Trees

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-11-2007   #1 (permalink)
$hay
Guest


 

Duplicating Directory Trees

Just updated the "Chronicles of a Script" post
Anyway, you can duplicate an exisiting directory tree (folders only)
to another location with this command

Copy-Item $env:windir -filter {$_.PSIsContainer}
d:\testingpath -recurse -force

$hay
http://scriptolog.blogspot.com



My System SpecsSystem Spec
Old 01-11-2007   #2 (permalink)
Keith Hill [MVP]
Guest


 

Re: Duplicating Directory Trees

"$hay" <no@addre.ss> wrote in message
news:OoAOyFbNHHA.4992@TK2MSFTNGP04.phx.gbl...
> Just updated the "Chronicles of a Script" post
> Anyway, you can duplicate an exisiting directory tree (folders only)
> to another location with this command
>
> Copy-Item $env:windir -filter {$_.PSIsContainer}
> d:\testingpath -recurse -force


This command does the same thing:

Copy-Item $env:windir -filter {$null} d:\testingpath -recurse -force

I don't think the scriptblock you are specifying for -filter is behaving
like you think it is.

--
Keith



My System SpecsSystem Spec
Old 01-11-2007   #3 (permalink)
Keith Hill [MVP]
Guest


 

Re: Duplicating Directory Trees

"Keith Hill [MVP]" <r_keith_hill@no.spam.thank.u.hotmail.com> wrote in
message news:OWcFOTbNHHA.1240@TK2MSFTNGP03.phx.gbl...
> "$hay" <no@addre.ss> wrote in message
> news:OoAOyFbNHHA.4992@TK2MSFTNGP04.phx.gbl...
>> Just updated the "Chronicles of a Script" post
>> Anyway, you can duplicate an exisiting directory tree (folders only)
>> to another location with this command
>>
>> Copy-Item $env:windir -filter {$_.PSIsContainer}
>> d:\testingpath -recurse -force

>
> This command does the same thing:
>
> Copy-Item $env:windir -filter {$null} d:\testingpath -recurse -force


And so does this:

Copy-Item $env:windir -filter '$null' d:\testingpath -recurse -force

The parameter type of -filter is string, so when you specify a scriptblock I
think you are getting just the "ToString()" representation of the
scriptblock e.g.:

344> {$_.PSIsContainer}.ToString()
$_.PSIsContainer

What made me wonder on this is that you were using $_ which in the context
of your command wouldn't represent a valid value i.e. the command starts the
pipeline and doesn't receive pipeline objects.

--
Keith


My System SpecsSystem Spec
Old 01-11-2007   #4 (permalink)
Andrew Watt [MVP]
Guest


 

Re: Duplicating Directory Trees

OK, Keith, I'll bite.

copy-item $env:windir -filter "anything" -destination C:\TestingPath6
-force -recurse

also copies directories only.

Yet if you omit the filter parameter files are copied too.

Do you understand why? At the moment I can't figure it out.

Andrew Watt MVP

On Thu, 11 Jan 2007 12:20:52 -0700, "Keith Hill [MVP]"
<r_keith_hill@no.spam.thank.u.hotmail.com> wrote:

>"Keith Hill [MVP]" <r_keith_hill@no.spam.thank.u.hotmail.com> wrote in
>message news:OWcFOTbNHHA.1240@TK2MSFTNGP03.phx.gbl...
>> "$hay" <no@addre.ss> wrote in message
>> news:OoAOyFbNHHA.4992@TK2MSFTNGP04.phx.gbl...
>>> Just updated the "Chronicles of a Script" post
>>> Anyway, you can duplicate an exisiting directory tree (folders only)
>>> to another location with this command
>>>
>>> Copy-Item $env:windir -filter {$_.PSIsContainer}
>>> d:\testingpath -recurse -force

>>
>> This command does the same thing:
>>
>> Copy-Item $env:windir -filter {$null} d:\testingpath -recurse -force

>
>And so does this:
>
>Copy-Item $env:windir -filter '$null' d:\testingpath -recurse -force
>
>The parameter type of -filter is string, so when you specify a scriptblock I
>think you are getting just the "ToString()" representation of the
>scriptblock e.g.:
>
>344> {$_.PSIsContainer}.ToString()
>$_.PSIsContainer
>
>What made me wonder on this is that you were using $_ which in the context
>of your command wouldn't represent a valid value i.e. the command starts the
>pipeline and doesn't receive pipeline objects.

My System SpecsSystem Spec
Old 01-11-2007   #5 (permalink)
$hay
Guest


 

Re: Duplicating Directory Trees

copy-item $env:windir -filter *.* -destination
C:\TestingPath6 -force -recurse

certainly did the job.
I have messed with the -exclude parameter instead, using various options and
it didn't worked.
guess i walked the wrong path

Cheers

$hay


"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
news:6d7dq2ltm5sceo2rm93trd9mv49p2h0ujf@4ax.com...
> OK, Keith, I'll bite.
>
> copy-item $env:windir -filter "anything" -destination C:\TestingPath6
> -force -recurse
>
> also copies directories only.
>
> Yet if you omit the filter parameter files are copied too.
>
> Do you understand why? At the moment I can't figure it out.
>
> Andrew Watt MVP
>
> On Thu, 11 Jan 2007 12:20:52 -0700, "Keith Hill [MVP]"
> <r_keith_hill@no.spam.thank.u.hotmail.com> wrote:
>
>>"Keith Hill [MVP]" <r_keith_hill@no.spam.thank.u.hotmail.com> wrote in
>>message news:OWcFOTbNHHA.1240@TK2MSFTNGP03.phx.gbl...
>>> "$hay" <no@addre.ss> wrote in message
>>> news:OoAOyFbNHHA.4992@TK2MSFTNGP04.phx.gbl...
>>>> Just updated the "Chronicles of a Script" post
>>>> Anyway, you can duplicate an exisiting directory tree (folders only)
>>>> to another location with this command
>>>>
>>>> Copy-Item $env:windir -filter {$_.PSIsContainer}
>>>> d:\testingpath -recurse -force
>>>
>>> This command does the same thing:
>>>
>>> Copy-Item $env:windir -filter {$null} d:\testingpath -recurse -force

>>
>>And so does this:
>>
>>Copy-Item $env:windir -filter '$null' d:\testingpath -recurse -force
>>
>>The parameter type of -filter is string, so when you specify a scriptblock
>>I
>>think you are getting just the "ToString()" representation of the
>>scriptblock e.g.:
>>
>>344> {$_.PSIsContainer}.ToString()
>>$_.PSIsContainer
>>
>>What made me wonder on this is that you were using $_ which in the context
>>of your command wouldn't represent a valid value i.e. the command starts
>>the
>>pipeline and doesn't receive pipeline objects.



My System SpecsSystem Spec
Old 01-11-2007   #6 (permalink)
Keith Hill [MVP]
Guest


 

Re: Duplicating Directory Trees

"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
news:6d7dq2ltm5sceo2rm93trd9mv49p2h0ujf@4ax.com...
> OK, Keith, I'll bite.
>
> copy-item $env:windir -filter "anything" -destination C:\TestingPath6
> -force -recurse
>
> also copies directories only.
>
> Yet if you omit the filter parameter files are copied too.
>
> Do you understand why? At the moment I can't figure it out.


Neither can I. :-(

--
Keith


My System SpecsSystem Spec
Closed Thread
Update your Vista Drivers Update Your Drivers Now!!

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
duplicating of photos when sending e-mail mikeygit Vista mail 3 02-24-2008 04:28 PM
Duplicating Quick Launch Toolbar Mitch Vista General 5 01-10-2008 04:21 PM
Duplicating pictures RP50 Vista music pictures video 6 10-25-2007 07:00 PM
Contacts folder duplicating itself? Tessiero Vista General 1 10-01-2007 04:01 PM
Horizonal Autoscroll of trees is the WORST new Vista feature MichaelDouglasKrause Vista General 19 09-19-2007 05:20 PM


Vistax64.com 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 2005-2008

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 47 48 49 50 51