I'm trying to create an Automator app that would work like this:
- You would drag any type of image file onto the app.
- The app would make a duplicate of the file, convert it to JPEG, scale it down to 500px, remove the " copy" part at the end of the filename.
- Upload the original file to a specific folder on my Dropbox account.
- When step 3 is done, upload the converted JPEG to another specific folder on my Dropbox account.
- Delete the converted JPEG locally when the process is finished.
Steps 1 and 2 are working. I've also found a shell script that can be used to upload files to Dropbox with a provided access token. So I can make it upload the converted JPEG, as that seems to be what the $1 variable is holding in the script.
Here's the shell script:
DROPBOX_TOKEN="YOUR DROPBOX ACCESS TOKEN GOES HERE"
FILE=$1
FILENAME=$(basename "$FILE")
UPLOAD=`curl -sX POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer $DROPBOX_TOKEN" \
--header "Dropbox-API-Arg: {\"path\": \"/$FILENAME\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @"$FILE"`
I'm also attaching this screenshot of how the current "Automator flow" looks like. In the current state of this "flow", the file that gets uploaded through the shell script is the converted file.
The part I'm stuck at is how to first upload the original image file with one shell script and then upload the converted file with another shell script. I guess that I have to store a reference for both in some way?
I'm also not quite sure how to specifically delete the JPEG after everything is done.


