Copy file structure – why is this not straightforward?

Hello again!

I’m having an issue with a script I’ve been working on. I’m simply trying to check if a file exists, and if it doesn’t I want to copy a few items to a specific folder. The file checking part is working just fine, however I can’t seem to get the copy part to work at all. Here’s the setup: I have my script in a folder on a removable drive. in that folder with the script are a few other folders with their own subfolders and files. These are the files I want to copy. When I run:

copy-item -path .* -destination c:folder -recurse -container 

It seems to work, but I get a few errors like this:

copy-item : Container cannot be copied onto existing leaf item. 

and the end result is most of the files make it to the destination, however the folder structure is completely broken. This seems like such an easy thing to accomplish, but I can’t seem to make it work. Please tell me how I’m screwing this up!


submitted by /u/Ubuntu_Linux_User
[link] [comments]

Leave a Reply