MacOS – How to make aliases go away when main file is deleted

aliasmacos

Is there a way to (automatically) delete all aliases when the file they are an alias to is deleted?

Best Answer

No - aliases are a combination of a sym link pointing to a place as well as a unique file ID to track that file if it moves so the alias won't be broken if the file still resides on the original volume. (the file ID changes across volumes and an alias will only remain valid if the relative path is correct if and when the file ID half is broken by a deletion).

So - for this to work, the system actively tries to reconnect the alias after a delete of the original file by design so automatically deleting an alias would ruin that chance to reconnect.

Even though your question makes great logical sense, it amounts to a re-design of what an alias is engineered to do.

A hard link is what you want to use if you want it to go away when the file is deleted finally.