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
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.
CodePudding user response:
I think with the Set Value of Variable and Get Value of Variable actions you can achieve what you're trying to do here.
This workflow provides an example of using these. You can set multiple different named variables, and then read and reuse them later. To get this workflow to work properly I had to select Ignore this action's input
for the Get step, otherwise it used both the value of example
(which was the filename of the file dropped onto the app) and also the output of Ask for confirmation (which was the filename again, so it tried to move the same file to the Trash twice).
When creating a variable you just choose New Variable...
from the drop-down menu. You then give it a name, and leave the Value box empty (and it gets set from the Set... action's input).
Once you have a Variable set up you can also drag it into some places (from the Variable section at the bottom of the window), as I've done here to make the file path show up in the Ask for Confirmation action. You can also remove any unused variables by right-clicking on the variable in the Variable section, and choosing Delete exampleVariable
Full steps which I think would complete your full workflow could be:
- Set Value of Variable first, to store your 'original filename' in variable
original
(or something), then the parts of the workflow you already have: - Duplicate file
- Convert to to JPEG
- Scale
- Remove "copy"
- Set Value of Variable
converted
to input - Your already-working upload shell script step
- Get Value of Variable to read
converted
back in (this should haveIgnore this action's input
ticked) - Move Finder Items to Trash to remove the JPEG file (could be a shell script to delete the file immediately)
- Get Value of Variable to read
original
back in (this should also haveIgnore this action's input
ticked) - Your upload shell script step again (to upload this time the original file)
- Display happy alert message