An open community 
of Macintosh users,
for Macintosh users.

FineTunedMac Dashboard widget now available! Download Here

Previous Thread
Next Thread
Print Thread
The Name of an Alias
#46844 11/13/17 06:04 PM
Joined: Aug 2009
Likes: 8
Ira L Offline OP
OP Offline

Joined: Aug 2009
Likes: 8
Let's say I have a file named "ABC.pdf". I create an alias, which by default is named "ABC.pdf alias".

Questions:
1. If I change the name of the alias to "XYZ.pdf alias" (nothing else has that name), will it still point to ABC.pdf?
2. If I change the name of ABC.pdf to XYZ.pdf and keep the alias as "ABC.pdf alias", will it still point to the newly named XYZ.pdf?

My thinking is that alias references are name independent and using something else to make the connection. Yes, I could do the checking myself, but would like a more technical resolution to my questions. Thanks.

Not interested in using a symbolic link at this time.


On a Mac since 1984.
Currently: 24" M1 iMac, M2 Pro Mac mini with 27" BenQ monitor, M2 Macbook Air, MacOS 14.x; iPhones, iPods (yes, still) and iPads.
Re: The Name of an Alias
Ira L #46845 11/13/17 07:49 PM
Joined: Aug 2017
Offline

Joined: Aug 2017
Yes and Yes, even both.
When you create an alias for an object, the system creates a small data file that includes the current path to the object, as well as the object's inode name. Each object's inode name is a long string of numbers, independent of the name you give the object, and guaranteed to be unique to any volume or drive your Mac uses. [1] The latter guarantees that it still works if either one or both names and location changes.

Note that aliases are resolved by the Finder, so Terminal may give unexpected results.

Re: The Name of an Alias
Ira L #46851 11/14/17 08:27 PM
Joined: Aug 2009
Offline

Joined: Aug 2009
when you create an alias, the Finder makes a document and interestingly enough, a resource fork, to contain an ALIS resource. As was previously mentioned, contains a string path to the file as well as the device guid + device inode of the file or folder. Either one of these is often enough to find a file, and any app that uses the mac os APIs to resolve it will have no problem with it. Terminal commands don't support aliases, but translation IS possible. If you rename a file, OR a folder / drive in the path of the file, and then try to use the gui to access it, it will discover one mode is invalid, and will use the other good mode to fix the first one, and then access the file normally.

If you change BOTH the inode AND the path, the alias will break. You already know how to change the path, but to change the inode simply make a different file by the same name in a different folder, and drag it into the original's folder. Finder will prompt you and you can replace it. Same path, different inode. If you then rename the file, you have changed its path and its inode, and any alias to it is now broken.

Terminal uses hard and soft symbolic links instead. Soft symbolic links are just the path part of an ALIS. Hard symbolic links are duplicate directory entries for the same inode, and so they're like the inode half of the ALIS, but can't cross volumes. The OS is weird with hard links... a file isn't truly deleted until ALL of the hard links (including the original one) are removed - if any of them exist, the file still exists. You can overwrite and replace a file all day long and soft ("symbolic") links to it will continue to work. You can rename or move a file all day long (or even rm it!) and hard links to it will continue to work. So each has its own specific advantages.

This applescript (callable in terminal with osascript) uses Finder to get the unix path of a Finder alias, which you can use to make or replace it with a hard or soft link.

tell application "Finder"
set theItem to (POSIX file "'${item_path}'") as alias
if the kind of theItem is "alias" then
get the posix path of (original item of theItem as text)
end if
end tell

I've seen a way to create a finder alias from a path (the reverse of the above) but I don't see it offhand here. Maybe buried in the sands of time?

It's interesting to see that Finder icons and aliases are really the only two resource fork resource types still actively in use in mac os.

oh also, in most cases when you access an alias with Finder, (cmd-click on it, or get info etc) mac os checks to see if the target's icon has changed. if it has, it usually changes the alias's icon to match it. Otherwise alias icons don't change when their target does.


I work for the Department of Redundancy Department
Re: The Name of an Alias
Virtual1 #46852 11/14/17 08:44 PM
Joined: Aug 2009
Likes: 15
Online

Joined: Aug 2009
Likes: 15
Great post! Thanks. smile

Aliases and symbolic links have been discussed before, but this explanation includes new facts that have expanded my understanding of the subject.


The new Great Equalizer is the SEND button.

In Memory of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire
Re: The Name of an Alias
Virtual1 #46855 11/14/17 11:11 PM
Joined: Aug 2009
Likes: 8
Ira L Offline OP
OP Offline

Joined: Aug 2009
Likes: 8
Thank you, one and all. cool


On a Mac since 1984.
Currently: 24" M1 iMac, M2 Pro Mac mini with 27" BenQ monitor, M2 Macbook Air, MacOS 14.x; iPhones, iPods (yes, still) and iPads.
Re: The Name of an Alias
Ira L #46884 11/17/17 07:39 PM
Joined: Aug 2009
Likes: 1
Offline

Joined: Aug 2009
Likes: 1
Originally Posted By: Ira L
Let's say I have a file named "ABC.pdf". I create an alias, which by default is named "ABC.pdf alias".

Questions:
1. If I change the name of the alias to "XYZ.pdf alias" (nothing else has that name), will it still point to ABC.pdf?


Yes.

Originally Posted By: Ira L
2. If I change the name of ABC.pdf to XYZ.pdf and keep the alias as "ABC.pdf alias", will it still point to the newly named XYZ.pdf?


Yes, if XYZ.pdf lives on a Mac-formatted local disk.

Maybe, if XYZ.pdf lives on a file server.

No, if XYZ.pdf lives on a Windows-formatted local disk.

The Mac uses several different techniques to point the alias to the file. It records both a unique ID of the file and also the path to the file. The unique ID of the file relies on the disk being Mac-formatted.

If the disk isn't Mac-formatted, it falls back to the path, Changing the name of the file breaks the path.

If the file lives on a server, it gets complicated, and it depends on a lot of factors, including the server protocol and mount point.


Photo gallery, all about me, and more: www.xeromag.com/franklin.html
Re: The Name of an Alias
tacit #46904 11/18/17 03:56 PM
Joined: Aug 2009
Likes: 8
Ira L Offline OP
OP Offline

Joined: Aug 2009
Likes: 8
Originally Posted By: tacit
Originally Posted By: Ira L
2. If I change the name of ABC.pdf to XYZ.pdf and keep the alias as "ABC.pdf alias", will it still point to the newly named XYZ.pdf?


Yes, if XYZ.pdf lives on a Mac-formatted local disk.

Maybe, if XYZ.pdf lives on a file server.

No, if XYZ.pdf lives on a Windows-formatted local disk.


Ahh, this is significant. In real life my original file ABC.pdf resides in Dropbox. So maybe the alias reference will survive, maybe it won't.

For my purposes the sensible thing would be to keep the name of the original document unchanged and only change the name of the alias.

Thanks again.


On a Mac since 1984.
Currently: 24" M1 iMac, M2 Pro Mac mini with 27" BenQ monitor, M2 Macbook Air, MacOS 14.x; iPhones, iPods (yes, still) and iPads.
Re: The Name of an Alias
Ira L #46932 11/19/17 11:42 PM
Joined: Aug 2009
Likes: 1
Offline

Joined: Aug 2009
Likes: 1
Keep in mind that files in Dropbox are also on your local disk. For the purpose of this discussion, they count as local files.


Photo gallery, all about me, and more: www.xeromag.com/franklin.html
Re: The Name of an Alias
tacit #46943 11/20/17 10:24 PM
Joined: Aug 2009
Likes: 16
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 16
Which brings up the question of aliases to files on the iCloud Drive or when the option to have the Documents and Desktop folders on iCloud is selected? In the case of the Documents folder being on iCloud there may or may not be a copy of the files on the local drive.


If we knew what it was we were doing, it wouldn't be called research, would it?

— Albert Einstein

Moderated by  alternaut, dkmarsh, joemikeb 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.4.33 Page Time: 0.020s Queries: 33 (0.014s) Memory: 0.6133 MB (Peak: 0.7017 MB) Data Comp: Zlib Server Time: 2024-03-28 10:05:42 UTC
Valid HTML 5 and Valid CSS