error "Expected “end” but found “on”."

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

Moderator: Mr_Noodle

Hi,
I try to use an Applescript to set a condition. But I always get an error. What is going wrong?
And the script is from this page:
https://www.noodlesoft.com/manual/hazel ... avascript/

Code: Select all
on hazelMatchFile(theFile, inputAttributes)
    — Add your logic here.
    — ‘theFile’ is an alias to the file that matched.
    — ‘inputAttributes’ is an AppleScript list of the values of any attributes you told Hazel to pass in.
    — Be sure to return true or false (or optionally a record) to indicate whether the file passes this script.
end hazelMatchFile


Image
Uhlhorn
 
Posts: 5
Joined: Fri Aug 18, 2017 11:56 am

That template is for external scripts. For embedded scripts, just enter the script you want to use.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Yes, I figured it out too. The script have to look like this:
(The linked web page should get a clue!)

Code: Select all
set root_fol to theFile

tell application "Finder"
   set files_ to count files of entire contents of root_fol
end tell

if files_ is 0 then
   return false
else
   return true
end if
Uhlhorn
 
Posts: 5
Joined: Fri Aug 18, 2017 11:56 am

I'll update the manual in a future patch.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support