You are not logged in.
I tried the following example from a very old (but very good) book from Stephen Kochan.
Applescript:
tell application "Finder"
-- define an alias
set testFile to ("Mojave:Users:martin:desktop:someFile") as alias
-- rename the name property
set name of testFile to "newFileName"
-- try to access the alias
get size of (info for testFile) -- alias not found
end tell
Do aliases still work in Mojave as they did in Leopard? Is there a workaround?
thanks in advance, Martin
Browser: Safari 605.1.15
Operating System: macOS 10.14
Offline
As far as I know, it's not a new feature.
The same behavior is got under 10.13.6.
Applescript:
set p2d to path to desktop as string
tell application "Finder"
-- define an alias
set testFile to (p2d & "someFile") as alias
log testFile --> (*alias SSD 1000:Users:**********:Desktop:someFile:*)
-- rename the name property
set name of testFile to "newFileName"
log testFile --> (*alias /Users/**********/Desktop/someFile*)
end tell
As you may check, after the renaming, the alias no longer point to an HFS path but the name of the pointed item is not modified.
Below is an edited version which works:
Applescript:
set p2d to path to desktop as string
tell application "Finder"
-- define an alias
set testFile to (p2d & "someFile") as alias
log testFile --> (*alias SSD 1000:Users:**********:Desktop:someFile*)
-- rename the name property
set newName to "newFileName"
set name of testFile to newName
log testFile --> (*alias /Users/**********/Desktop/someFile*)
set testFile to (p2d & newName) as alias
log testFile --> (*alias SSD 1000:Users:**********:Desktop:newFileName*)
size of testFile --> 66463
end tell
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 25 février 2021 19:05:50
Offline
Do aliases still work in Mojave as they did in Leopard?
It's not directly an OS change -- they just don't work on APFS format disks.
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline
It's not directly an OS change -- they just don't work on APFS format disks
I tried my original script on ElCapitan and it works...
Though that's no solution for Mojave, but thank you nevertheless
Last edited by Kuulest (2021-02-25 04:39:12 pm)
Offline
I tried my original script on ElCapitan and it works...
El Capitan did not use APFS format drives.
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline
Yes, I know. Therefore I've tested on ElCapitan and it worked.
Offline
My boot volume, an external SSD, is an APFS device.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 26 février 2021 08:09:49
Offline
To add to Shanes post:
Any upgrade or install to Mojave convert HFS+ to APFS filesystem. And the only way to get future
Software Update the boot drive need to be AFPS. So would it be possible to have Mojave on HFS+, answer is yes with Carbon Copy Cloner.
Its a reason why any macOS beyond High Sierra should be installed on SSD.
Last edited by Fredrik71 (2021-02-26 10:58:54 am)
if you are the expert, who will you call if its not your imagination.
Offline
My boot volume, an external SSD, is an APFS device.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 26 février 2021 08:09:49
Your script doesn't meet my problem. You defined a new alias for the renamed file and of course you can access the properties with the new alias. My script was intended to do the following:
tell application "Finder"
set folderName to (desktop as text)
set thisAliasStaysForever to (folderName & fileName) as alias
-- you can tinker in the properties as you like as long you don't change the name property
set extension hidden of thisAliasStaysForever to false -- just for example
set name of thisAliasStaysForever to "somethingDifferent"
-- the following doesn't work any longer with APFS but on Mac OS Extended
doSomethingWith(thisAliasStaysForever)
end tell
Browser: Safari 605.1.15
Operating System: macOS 10.14
Last edited by Kuulest (2021-02-26 03:19:19 am)
Offline
I tried to show you that renaming an alias is no longer reflected in the variable storing the alias when the hosting device is an APFS one.
As I wrote, in such case, renaming an alias changes the content of the variable whose HFS path is replaced by a POSIX path which doesn't reflect the new name.
This is why I urged you to build the new pathname by yourself.
For me it's not a problem because, for years I no longer use the dinosaur named "Finder" for such tasks.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 26 février 2021 12:37:21
Offline
now I understand your intention. Though it doesn't make sense to me, to create a new alias after the name has been changed. This contradicts the reason for using aliases. I just worked through Kochans book and was stuck with this issue, so I had to ask.
Which alternative to Finder do you use? Is it scriptable?
Operating System: macOS 10.14
Offline
I use System Events or ASObjC.
Finder is triggered only when I need to manipulate windows which I does rarely.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 26 février 2021 15:18:13
Offline
This isn't the issue raised by the OP, but it might be worth distinguishing between an alias and an alias file. An alias file works as expected with recent versions of macOS and will continue to point to the original file even if that file is renamed.
Also, while on the topic of aliases not working as expected, it might be noted that aliases often do not work with System Events if macOS Catalina is being used. I don't know if this has been fixed in Big Sur.
https://macscripter.net/viewtopic.php?pid=199777
2018 Mac mini - macOS Catalina
Offline
distinguishing between an alias and an alias file
Initially, they were much the same thing -- that's why they were called aliases in scripting. They were both handled by pre-OS X code known as alias manager. Alias files were changed at one point to use the more modern bookmark format, and AppleScript is the only thing still using the alias manager. So it's no surprise the alias manager wasn't updated for APFS.
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline