I was trying the accepted solution here: But it doesnt work, and my comment on the accepted solution is not getting a response.
I am trying to copy all pictures I have in my Pictures drive (only PNG, JPG, without the video files) to a different drive, but having no luck.
Ideally I want to copy recursively, but to a flat destination (not mirroring the source sub-directories)
I tried this command:Copy-Item -path "C:\Users\genadi\Pictures\" -include "*.JPG", "*.PNG" -Destination "D:\" with and without -recurse but nothing happens.
Ideally, I want a script that will 1) reduce original size of all JPG and PNG pictures (including all sub-folders) and 2) copy the reduced size to specified destination.
Currently my originals are about 20GB, I need to fit them on a flash drive for display/printing purposes etc. and easily repeat this when needed (hence why script would be nice).
1 Answer
That's because the object name returned by the cmdlet doesn't include the extension, you need to append \*. I'm not sure if Copy-Item allows you to "collapse" the destination directory, so I would use Get-ChildItem with -Recurse and pipe it to Copy-Item
Get-ChildItem -Path "C:\Users\genadi\Pictures\*" -Include *.jpg,*.png -Recurse | Copy-Item -Destination D:\ 1