Having applescript issue with getting the name of the file

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

Moderator: Mr_Noodle

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?
scottfwalter
 
Posts: 49
Joined: Thu Jan 03, 2013 11:10 am

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
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Thanks. I'm brand new to AppleScript. I never really had a need for it till I started to use Hazel :-)
scottfwalter
 
Posts: 49
Joined: Thu Jan 03, 2013 11:10 am


Return to Support