Alex Rivera | Logout

PowerShell implementation of xcopy

Asked 2011-09-07T09:27:08.927
22

Is there a way to replicate an xcopy functional using powershell?

I thought it was an easy question until I tried some cmdlets.

Let's imagine I've got a folder structure like:

src

|-a

|-b

There're files in each folder of course. I need to copy contents of Src to some folder Dst.

With xcopy it'd be like this:

xcopy src dst\ /e /y

PS analog would be something like this:

copy-item src dst\ -force -recurse -verbose

Works great... the first time. The second time it creates a subfolder dst\src and puts files there!

I can't figure out any easy workaround. Can you?

p.s. I know I can use xcopy in PS.

Edit
Report

1 Answer

36
copy-item c:\\src\\* c:\\dst -force -recurse -verbose 
answered 2011-09-07T10:08:14.523

Your Answer