Jump to content

Run script : getting in your script the path of the file you want to run the script against.

Recommended Posts

After literally hours, I finally find a solution to add a drop shadow effect on a given .png file.


The "one-liner" I found is working as I could make it work in zsh (cf. the image below).


The problem I have is I do not know how to make it work in a file action with a run script action.


I simply attached a file action to this run script action. 




My question is: how do I do for Alfred to get the value /PathToMyFile.png which is the path of the file I want to add the drop shadow effect?


Thank you.

Link to post

“With input as argv” means the filepath(s) are passed to your script as command-line arguments. In shell, you access them with $1, $2 etc.


So you replace "PathToMyFile.png" with "$1".


I’d be surprised if that script actually works, since convert isn’t a standard command. Normally, you’d need to specify its full path, i.e. /usr/local/bin/convert.

Link to post
  • 2 weeks later...

1°) Sorry for the late reply I didn't see any notification about your answer. Thank you for the precision about "argv". Makes me understand a little bit more about how Alfred works with scripts. 


2°) I changed the script to: 



/usr/local/bin/convert "$1" -bordercolor white -border 5 \( +clone -background black -shadow 80x3+2+2 \) +swap -background white -layers merge +repage "$1"


It is now working like a charm!


Thank you!


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...