Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

Copy-Item doesn't have --no-clobber option


cp(1) has -n or --no-clobber option. It makes cp not overwrite existing files. This option is useful when you copy only newly created files.


In PowerShell, Copy-Item cmdlet doesn't have options equivalent to --no-clobber of cp. Copy-Item -Confirm prompts you for confirmation even if there are no existing files on destination.


You have to check existence of files on destination folder one by one.