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

copy-item down through folders

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-29-2008   #1 (permalink)
Leo Tohill
Guest


 

copy-item down through folders

It seems simple: I just want the equivalent of
xcopy /S
which copies a full directory tree.

copy-item source target -recursive
does not give the desired results if a subfolder to be copied already exists
in the target tree. In that case, copy-item does not proceed to examine the
members of the folder, to copy them.
I want the target to be refreshed from the source.
How to?
THanks,
Leo



My System SpecsSystem Spec
Old 01-29-2008   #2 (permalink)
Kiron
Guest


 

Re: copy-item down through folders

That is a bug in Copy-Item. Maybe the function in this post helps:

http://groups.google.com/group/micro...A16EB51@xxxxxx

--
Kiron
My System SpecsSystem Spec
Old 01-29-2008   #3 (permalink)
Marco Shaw [MVP]
Guest


 

Re: copy-item down through folders

Leo Tohill wrote:
Quote:

> It seems simple: I just want the equivalent of
> xcopy /S
> which copies a full directory tree.
>
> copy-item source target -recursive
> does not give the desired results if a subfolder to be copied already exists
> in the target tree. In that case, copy-item does not proceed to examine the
> members of the folder, to copy them.
> I want the target to be refreshed from the source.
> How to?
> THanks,
> Leo
>
>
Check out:
http://www.bsonposh.com/modules/wordpress/?p=38

It might provide what you want.

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 01-29-2008   #4 (permalink)
Leo Tohill
Guest


 

Re: copy-item down through folders

Kiron, your solution doesn't address the existence of folders at any depth in
the target, does it?

"Kiron" wrote:
Quote:

> That is a bug in Copy-Item. Maybe the function in this post helps:
>
> http://groups.google.com/group/micro...rshell/msg/332
> 7f2d1544e7fb6?as_umsgid=6CAEDDC7-0F1A-4B21-8FB0-E6102A16EB51@xxxxxx
>
> --
> Kiron
>
My System SpecsSystem Spec
Old 01-29-2008   #5 (permalink)
Kiron
Guest


 

Re: copy-item down through folders

The function will _copy_ every folder and file of a source folder to a target folder. If the target folder has more folders than the source - at any depth - nothing happens to them, i.e., they'll remain. The function does not synchronize the source and target, just copies everything from the source to the target maintaining the source's structure.

--
Kiron
My System SpecsSystem Spec
Old 01-29-2008   #6 (permalink)
Kiron
Guest


 

Re: copy-item down through folders

The function will overwrite any existing folder/file - Hidden, ReadOnly - in the target without prompting.
The function is equivalent to cmd /c xcopy /e

cmd /c xcopy /?
.
.
.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
.
.
.

--
Kiron
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can the copy-item cmdlet be used to copy public folders to C: ? JoshGfromPortland PowerShell 8 06-09-2008 09:03 PM
copy-item changing files attributes on network copy failures jas PowerShell 4 01-31-2008 12:39 PM
Getting Copy-Item to display messages (like the old COPY command in CMD.EXE) ?? Marc Scheuner PowerShell 15 10-26-2007 02:41 AM
Copy-Item JW PowerShell 4 05-03-2007 04:19 PM
Copy-Item or Copy-ItemProperty and Remote Registry. Brandon Shell PowerShell 1 01-09-2007 10:51 AM


Update your Vista Drivers Update Your Drivers Now!!

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