Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get count of files copied using Copy-item

Tags:

powershell

I am using Copy-Item command to copy the multiple files from one location to another. In that, I want to get the count of files that are copied to destination.

If the above one is not possible, can we get 'True' if at least one file is copied and 'False' if none of the files are copied. I tried this but could not able to get exact one.

Thanks, Dinesh

like image 823
Dinesh Kumar Avatar asked Oct 24 '25 10:10

Dinesh Kumar


1 Answers

use -passthru to create output for commands that normally run silent.

(Copy-Item -Recurse $srcPath -Destination $destPath -passThru).count
like image 194
ArcSet Avatar answered Oct 26 '25 07:10

ArcSet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!