Extract files with specific file extension and keep directory structure?

I have a lot of .CR2 and .ARW files mixed together in a directory structured by date (2016 has the folder 06 and 07 within it with a folder for each day in them. So a file could be located in 2016/06/03 for example).

I want to extract the .ARW files into a separate folder while keeping the structure. Is this possible?

That is, I want to have two 2016 folders with the same structure but in one, there should only be .ARW files and in one there should only be .CR2 files.


These rsync commands should do what you’re looking for

This will do ARW

rsync -arvz --progress --include='*.ARW' --include="*/" --exclude="*" ./source-dir-2016 ./target-ARW-2016

And this will do CR2

rsync -arvz --progress --include='*.CR2' --include="*/" --exclude="*" ./source-dir-2016 ./target-CR2-2016

I used this post for a source of information.

Leave a Reply

Your email address will not be published. Required fields are marked *