Solved

copy-item : create source folder in destination

Posted on 2013-11-18
5
1,113 Views
Last Modified: 2013-11-18
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
Comment
Question by:Sybux
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39656852
Why not..
Copy-item -path r:\bob -Destination P:\ -Recurse -Force
0
 

Author Comment

by:Sybux
ID: 39656939
because time to time, destination name is not original name :) It should be too easy
0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 39656968
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
 
LVL 40

Expert Comment

by:Subsun
ID: 39656969
Try..
copy-item -path "r:\bob\" -Destination p:\bob -Force -Recurse

Open in new window

0
 

Author Closing Comment

by:Sybux
ID: 39657043
get-ChildItem was the tip. Thanks
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now