0

The folder named "z:\original" has hundreds of sub-folders containing multiple copies of the same .jpg files. I wanted to copy all .jpg files into a folder named "z:\dump" WITHOUT the folder structure and hopefully overwrite most of the copies. I used

copy-Item -path "Z:\original" -filter "*.jpg" -Destination "Z:\dump" -recurse -verbose

but this recreated the structure with the .jpg files. How can I dump all files into a single folder, using PowerShell?

1 Answer 1

1

Use combination of dir/Get-ChildItem and Copy-Item with pipeline.

$_.FullName - Full path to jpg file

$_.Name is file name only

Get-ChildItem Z:\original\*.jpg -Recurse | %{Copy-Item $_.FullName "Z:\dump\$($_.Name)"}

You might need to add -Force to overwrite same files

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.