• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1650
  • Last Modified:

copy-item : create source folder in destination

Hi,

I'm trying to make a very simple copy of a folder from one location to another location like this :

copy-item -path r:\bob -Destination p:\bob

Problem is that copy-item create a bob subfolder in the destination so that I'm getting this :

p:\Bob\bob ?!!?

What the hell is the command to avoid this ?

Thx in advance
0
Sybux
Asked:
Sybux
  • 2
  • 2
1 Solution
 
SubsunCommented:
Why not..
Copy-item -path r:\bob -Destination P:\ -Recurse -Force
0
 
SybuxAuthor Commented:
because time to time, destination name is not original name :) It should be too easy
0
 
footechCommented:
If the destination doesn't already exist, it will do as you want.  If it does exist, then the following will copy the source folder and all subfolders.
copy-item -path r:\bob\* -Destination p:\bob -recurse

Open in new window


If you only wanted to copy the files directly in the source folder and ignore subfolders, then you would have to do a Get-ChildItem and pipe the results to Copy-Item.
0
 
SubsunCommented:
Try..
copy-item -path "r:\bob\" -Destination p:\bob -Force -Recurse

Open in new window

0
 
SybuxAuthor Commented:
get-ChildItem was the tip. Thanks
0

Featured Post

SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now