Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1699
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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