How can I reverse lookup an alias, ie. find what links to a folder?

JevermannNG
Contributor II

I am looking for a way to find all Aliases which link to the "OneDrive-MyCompany" folder in ~/Library/CloudStorage

When I use

mdfind -name "OneDrive-MyCompany"

It only finds the original folder but not the Alias which is in "$HOME".

mdfind "kMDItemKind == 'Alias'"

Does not show any output ...

2 REPLIES 2

sdagley
Esteemed Contributor II

@JevermannNG Short of examining every file within a directory to see if it's an alias and then resolving it to see what it points to I don't think you're going to find that information easily. There is no requirement an alias' name match the name of the file/folder it's pointing to, and there's no attribute on a file/folder that tracks any aliases that have been created for it.

JevermannNG
Contributor II

I am looking for a different way now, but using "find" does not list me the Alias of OneDrive which is located in $Home/

The following command line does not find the Alias in "$HOME/OneDrive - CompanyName"
sudo find $HOME/ -name "OneDrive - CompanyName" -depth +1 -print 2>&1 | grep -v "Operation not permitted"

Is there something wrong in the command line or is "find" not able to find "Finder Alias" ?