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

  • 1
    Welcome to Ask Different. Please see How to Ask for tips on asking questions. If you're looking for help with a script, please edit your question to include the script that's giving you errors. If you're looking for someone to write the script for you, you should add that request into your question.
    – fsb
    Nov 2 '18 at 12:13
  • Is there always a space character after the DSCnnn part in the JPEG name?
    – nohillside
    Nov 2 '18 at 12:41
  • nohillside: yes!
    – Guido Wido
    Nov 2 '18 at 13:31
  • 1
    To the close voter who selected "This question does not appear to be about Apple hardware or software within the scope defined in the help center." as the reason, this question is about Automator which is a default application in macOS... so, IMO this question is on topic however, the OP shows no research effort and why I wouldn't up vote the question but, I'm not going to vote to close it since there is a viable answer offered. Nov 3 '18 at 0:13

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##*/}"


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

  • 1
    You really do not need both a Run Shell Script action and a Run AppleScript action! Just use the following compound command, awk '{print $1}' <<< "${1##*/}" in the Run Shell Script action, delete the Run AppleScript action and in the Options for the Spotlight action check the [√] Ignore this actions input check box, so there is a disconnect between it and the previous action, the Set Value of Variable action should not be directly connected to the next action, in this use case. Nov 2 '18 at 23:31
  • @user3439894 nice, I'm updating the answer Nov 2 '18 at 23:38
  • Thanks a lot! Work fine but with "ignore this actions" input check box unchecked! Thanks to all!
    – Guido Wido
    Nov 3 '18 at 9:33
  • can I do something to make it work with multiple files selections? or folder?
    – Guido Wido
    Nov 3 '18 at 9:59
  • @GuidoWido you can create a Folder Action instead of a Service, so whenever you paste a file in that folder the workflow will run. Plz mark it as a right answer if it solved your problem! Nov 3 '18 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .