tell application "Finder"
set some_file to alias "Macintosh HD:Users:[myaccount]:[Dropbox Folder name]:hamlet.qlab4"
set extension hidden of some_file to true
end tell
tell application "Finder"
set some_file to alias "Macintosh HD:Users:[myaccount]:[Dropbox Folder name]:hamlet.qlab4"
set extension hidden of some_file to false
end tell
On 5 Mar 2020, at 16:43, 'MattM' via QLab <ql...@googlegroups.com> wrote:
--
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/e8dc9a7f-032a-4b15-9b9d-d72c1fc94377%40googlegroups.com.
tell application "Finder"
set thisFile to alias "Macintosh HD:Some Audio File.aif"
open thisFile
end tell
Assuming you have iTunes set to be the application associated with .aif files, this will cause the file to open in iTunes and start playing.
Now, having changed nothing else, take the .aif off the alias declaration in the above script, so that it now reads:
tell application "Finder"
set thisFile to alias "Macintosh HD:Some Audio File"
open thisFile
end tell
This will throw a compile error. AppleScript looks for the file, and not finding it, will not even compile this script.
Now comes the weirdness. In the Finder, select your audio file and choose "Get Info." Click the check box to "hide file extension" so that it now displays as just "Some Audio File" in the Finder.
Run the first script above, with the file extension included in the alias:
tell application "Finder"
set thisFile to alias "Macintosh HD:Some Audio File.aif"
open thisFile
end tell
Even though we've changed the display name of the file to NOT show the extension, this script will still compile and run. It's as if macOS gives the user a free pass and allows you to specify the extension, even if it's hidden.
NOW, try running the second script again -- the one that failed above when the extension was showing:
tell application "Finder"
set thisFile to alias "Macintosh HD:Some Audio File"
open thisFile
end tell
with the extension hidden in the Finder -- surprise! The above script now compiles and, if you run it, iTunes will launch and start playing the file.
So, to review:
1) If the extension is visible in the Finder, the extension is required and you cannot reference the file in an AppleScript alias without including the extension in the alias declaration. Otherwise, the script will not even compile.
2) If the extension is hidden in the Finder, it doesn't matter whether you include the extension or not. MacOS pattern-matches on both, and both will compile and execute without incident.
My initial thought after we were chatting about this earlier today was to suggest that "well, macOS always requires you to include the extension, so, for maximum "mac-like" behavior, and for consistency's sake, in QLab's implementation of AppleScript and OSC, we should always be required to include the extension as well."
But it turns out that macOS is actually surprisingly inconsistent on this point, too.
My next thought was, if the F53 folks are going to add, as Chris says, an extra pass to search the current document names with any file extensions removed, would that mean that QLab's OSC queries would pattern-match on both, e.g. "hamlet" and "hamlet.qlab4", but AppleScript would not? Are you able to do the same kind of extra pass on AppleScript statements passed to QLab, though? Or is an AppleScript statement passed to QLab going to fail according to the same criteria I've laid out above?
Ideally macOS would be consistent about this; it's not. I guess the question is whether the fix -- adding an extra pattern-matching pass -- is going to fix OSC but break AppleScript (or have no effect on AppleScript's default behavior, because it's a file system call?) on this point.
So my other thought/observation was -- if macOS will *always* accept references to a file if the extension is included, at the very least, maybe QLab should follow the same policy? That is, if you've got your workspace set to hide the extension -- "hamlet" -- you can still specify "hamlet.qlab4" in your OSC statements (and, as shown above, your Applescripts) -- and they will always work.
Having QLab ignore "hamlet.qlab4" when the extension is hidden has always felt like the wrong behavior to me, more so than the other way around.