MacOS – Request Applescript to copy only one file type from 2 folders, into a 3rd folder

applescriptautomatorcatalinamacos

Hi I've been trying to find utilities that will do this but I am guessing applescript/Automator on Catalina mac would work too.

Basically I have 2 folders with all kinds of books (.pdf, .mobi and .epub) and subfolders too. I want to only copy files of extension epub type in these 2 folders, into a 3rd folder.

So by running the script the third folder would have only unique EPUB files from the former two folders.

Can anyone please advise me how to write this up in Automator? Thanks!

Best Answer

If you want to run this in Terminal you can use

find /path/to/top/of/source -type f -iname '*.epub' -exec cp '{}' /path/to/target/ \;

This will duplicate all files, which might be heavy on disk space depending on the number and size of your Epubs. You can also just link them by using

find /path/to/top/of/source -type f -iname '*.epub' -exec ln '{}' /path/to/target/ \;