Shell Scrip$1 to reference file being processed-not working

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

EDIT: sorted it out but did not want to delete post, in case there is another newbie doing the same thing I did.

The Action is running a python3 script on current file (using Action>Run Shell Script>embedded script)

UI-the embedded script Popup says
use $1 to refer to the file being processed


and in User Guide
Unlike AppleScript and JavaScript, shell scripts in Hazel can neither accept import attributes nor export custom attributes. Shell scripts take just one argument, $1 , which is the full path of the file or folder being processed.


further on
Along the same lines, keep in mind that $1 returns the full path, not a relative path, and that the path may contain spaces (which can cause errors in many commands if not properly accounted for). To prevent problems in the sh family of shells (sh, tcsh, bash, etc.), enclose the path (or at least the $1 ) in quotation marks.


Works successfully when "full path name of the file" is hardcoded in the embedded shell script e.g. "/dir/dir/my_filename.PDF".. I had to hard code the full path of the file as the python3 script must be executed from a specific directory.

When I replace the "full path name of the file" including the quotation marks with "$1", it fails. Also tested with replacing with $1 (no quotation marks) and it failed.

EDIT: working now. I had one extra space in the line executing the python script, in the embedded script. When I removed the space that should not of been there, the $1 turns GREEN and the quotation marks turn RED. very cool.
NoodleNewbie
 
Posts: 34
Joined: Fri Jul 13, 2018 5:17 pm

Return to Support