Solved

copy-item : create source folder in destination

Posted on 2013-11-18
5
1,063 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
Comment Utility
Why not..
Copy-item -path r:\bob -Destination P:\ -Recurse -Force
0
 

Author Comment

by:Sybux
Comment Utility
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
Comment Utility
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
Comment Utility
Try..
copy-item -path "r:\bob\" -Destination p:\bob -Force -Recurse

Open in new window

0
 

Author Closing Comment

by:Sybux
Comment Utility
get-ChildItem was the tip. Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

15 Experts available now in Live!

Get 1:1 Help Now