Page 1 of 1

Having applescript issue with getting the name of the file

PostPosted: Thu Jan 03, 2013 3:47 pm
by scottfwalter
I have an AppleScript with this:

set the_name to name of this_file

however the hazel log gives me this error:

executing AppleScript on file /Users/scott/Desktop/Hazel Testing/a16.pdf.
2013-01-03 13:42:06.835 hazelworker[9776] AppleScript error: {
NSLocalizedDescription = "Can\U2019t get name of alias \"Macintosh HD:Users:scott:Desktop:Hazel Testing:a16.pdf\".";
NSLocalizedFailureReason = "Can\U2019t get name of alias \"Macintosh HD:Users:scott:Desktop:Hazel Testing:a16.pdf\".";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: null()>";
OSAScriptErrorBriefMessageKey = "Can\U2019t get name of alias \"Macintosh HD:Users:scott:Desktop:Hazel Testing:a16.pdf\".";
OSAScriptErrorMessageKey = "Can\U2019t get name of alias \"Macintosh HD:Users:scott:Desktop:Hazel Testing:a16.pdf\".";
OSAScriptErrorNumberKey = "-1728";
OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'obj '{ 'form':'prop', 'want':'prop', 'seld':'pnam', 'from':'obj '{ 'want':'alis', 'from':null(), 'form':'name', 'seld':'utxt'(\"Macintosh HD:Users:scott:Desktop:Hazel Testing:a16.pdf\") } }>";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";


Any ideas?

Re: Having applescript issue with getting the name of the fi

PostPosted: Thu Jan 03, 2013 4:40 pm
by a_freyer
Your issue is that "name" is not a global applescript property.

This should work for you:

Code: Select all
tell application "Finder" to set the_name to name of theFile

Re: Having applescript issue with getting the name of the fi

PostPosted: Thu Jan 03, 2013 5:23 pm
by scottfwalter
Thanks. I'm brand new to AppleScript. I never really had a need for it till I started to use Hazel :-)