Say you have this folder

foo

You can run this command in Bash

cp -r --no-target-directory foo bar

and it will create

foo
bar # same contents as foo

Then you can re-run the command without changing the result. How can you do this with PowerShell?

有帮助吗?

解决方案 2

So the problem is that

cp -r -fo foo bar

only works if bar does not exist and

cp -r -fo foo/* bar

only works if bar exists. So to work around, you need to make sure bar exists before doing anything

md -f bar
cp -r -fo foo/* bar

其他提示

This will do that. It will create the bar folder, which will contain everything that foo contains.

copy-item .\foo .\bar -recurse -force
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top