macOS Automator – Script to Select Part of File Name, Find File, and Copy to Another Folder

automatorcopy/pastefilefindermacos

I have 3 folder:

JPG folder: contains my modified JPG files, the name of file is (examples): DSC02996 20181027 201438 (LR).jpg

RAW folder: contains my RAW files, the name of file is (examples): DSC02996.RAW

DESTINATION folder: i want to copy here my RAW file.

I need a script that looks for the beginning of the name in the JPG folder, then looks for the file in the RAW folder and copies the result to the DESTINATION folder.

It's possible?

Thanks in advance.
Guido

Best Answer

Open Automator, create a new Service and mount your workflow like this:

enter image description here

Save it and name as CopyRaw or something you like.

Shell Script:

awk '{print $1}' <<< "${1##*/}"

Usage:

Righ click the file you want and click on your service CopyRaw.