AppleScript theFile Alias

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

Moderator: Mr_Noodle

AppleScript theFile Alias Wed Nov 16, 2022 1:16 pm • by imakers
Hi - I'm just getting started with Hazel so forgive what I hope is a simple issue to solve!

I'm trying to use an Applescript to query a file with MediaInfo to Hazel with the custom export parameters used to rename the file... however I've been getting empty results back for the exported parameters and so I've been trying to debug. It looks like I'm struggling with theFile as an input parameter.

I've taken it back to basics and simply using
Code: Select all
display dialog "File is: " & theFile
as an embedded AppleScript. I get an error running this though and in the debug log I'm seeing "can't make alias" errors

2022-11-16 17:05:36.263 hazelworker[15567] OSAScript error: {
NSLocalizedDescription = "System Events got an error: Can\U2019t make alias \"Macintosh HD:Users:imakers:Movies:Hazel Test:Bottom - Series 3 - Episode 3 - Break.m4v\" into type string.";
NSLocalizedFailureReason = "Can\U2019t make alias \"Macintosh HD:Users:imakers:Movies:Hazel Test:Bottom - Series 3 - Episode 3 - Break.m4v\" into type string.";


I'm hoping I'm doing something really obviously wrong? Any pointers or thoughts how I might fix it please? Thanks!
imakers
 
Posts: 2
Joined: Wed Nov 16, 2022 1:08 pm

Re: AppleScript theFile Alias Thu Nov 17, 2022 10:58 am • by Mr_Noodle
Try doing something like "set path to theFile as string" and use "path" after that.
Mr_Noodle
Site Admin
 
Posts: 11251
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: AppleScript theFile Alias Thu Nov 17, 2022 11:21 am • by imakers
Thank you! Good shout - it's the "as string" I needed...

After a bit of trial and error (and a bit of extra googling) I found I needed to POSIX too... so I found that this worked:
Code: Select all
set filename to "'" & POSIX path of (theFile as string) & "'"


Thanks for your help!
imakers
 
Posts: 2
Joined: Wed Nov 16, 2022 1:08 pm


Return to Support