Search code examples
macosterminalchecksumautomator

calculate Shasum for multiple files in Mac automator


I'm trying to run shasum on mulitple files and copy the output to the clipboard.

In the terminal it's simple calculate the checksum on multiple files.

shasum /Volumes/EOS_DIGITAL/DCIM/100CANON/A99A0708.MP4 /Volumes/EOS_DIGITAL/DCIM/100CANON/A99A0710.MP4 /Volumes/EOS_DIGITAL/DCIM/100CANON/A99A0711.MP4 /Volumes/EOS_DIGITAL/DCIM/100CANON/A99A0712.MP4 /Volumes/EOS_DIGITAL/DCIM/100CANON/A99A0713.MP4 /Volumes/EOS_DIGITAL/DCIM/100CANON/A99A0714.MP4 /Volumes/EOS_DIGITAL/DCIM/100CANON/A99A0715.MP4

and the ouput is the checksum /path for each file on a seperate line

in automator run shell script shasum /Volumes/EOS_DIGITAL/DCIM/card2/A99A0686.MP4 outputs the checksum and path then copy to clipboard does it's thing.

when I try dragging multiple files in the automator work flow i get "Run Shell Script" encountered an error :zsh:2: exec format error:/path zsh:3: exec format error:/path zsh:4: exec format error:/path .... repeating for how many files I try dragging in to the work flow.

When the workflow is saved as an application it outputs a single checksum that doesn't match any one file.

Is there a way to get the application to output the checksum for each file and copy all the results to the clipboard so I can paste them into a spread sheet as a group.


Solution

  • In your Run Shell Script action, set the 'Pass input:' pulldown menu to 'as arguments', then use the following code:

    for f in "$@"
    do
        shasum "$f"
    done