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 - copy-item down through folders

Reply
 
Old 01-29-2008   #1 (permalink)
Leo Tohill


 
 

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


 
 

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]


 
 

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


 
 

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


 
 

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


 
 

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
Reply

Thread Tools


Similar Threads
Thread Forum
Copy-Item : Container cannot be copied onto existing leaf item. PowerShell
Can the copy-item cmdlet be used to copy public folders to C: ? PowerShell
copy-item changing files attributes on network copy failures PowerShell
Getting Copy-Item to display messages (like the old COPY command in CMD.EXE) ?? PowerShell
Copy-Item or Copy-ItemProperty and Remote Registry. PowerShell


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