Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 08-11-2003, 12:53 PM   #1
macgruder
Prospect
 
Join Date: Aug 2003
Posts: 45
How do I delete every alias on a disk

Seems like a strange request, but I have a problem on my backup disk with psync in that it seems to be confused by alias files on the target disk, so I want to

Delete all aliases on a the target (backup disk) before I do the backup.

How would I do this?
macgruder is offline   Reply With Quote
Old 08-11-2003, 05:07 PM   #2
robophilosopher
Triple-A Player
 
Join Date: Mar 2003
Location: Silver Spring, MD, USA
Posts: 57
Talking UNIX Solution

If, as I understand it, Mac OS X aliases are UNIX-style symlinks, you should be able to delete all aliases on a drive (or, in a directory) by opening a terminal window and typing:
Code:
find /path/ -type l -exec rm -f {} \;
(note that there is a space between {} and \; )

This translates to "find files in the directory /path/ (and all subdirectories) of type symbolic link (Alias). For each you find, execute the remove command, and don't ask me for confirmation." Keep in mind that UNIX-style removing will not move files to the Trashcan, so be careful! And make sure to get your path right, or you could wind up deleting all aliases on your computer, which would royally screw up iPhoto libraries, etc etc.

I don't know what the path would be for a second Mac HD, as I don't have one... but the "mount" command should provide clues.

If you just run
Code:
find /path/ -type l
you'll be able to see a list of the files that will be deleted without actually deleting them. A good way to check yourself.

Hope this helps!
robophilosopher is offline   Reply With Quote
Old 08-11-2003, 07:16 PM   #3
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
the shell command find, above, is only going to find unix style symbolic links.

finder style aliases are not findable from the shell, without considerable evaluation.

so, use the finder find facility to find finder aliaii ;]

there, you can select the results and command-delete them to the trash
mervTormel is offline   Reply With Quote
Old 08-11-2003, 11:38 PM   #4
macgruder
Prospect
 
Join Date: Aug 2003
Posts: 45
Re: UNIX Solution

Quote:
Originally posted by robophilosopher
If, as I understand it, Mac OS X aliases are UNIX-style symlinks, you should be able to delete all aliases on a drive (or, in a directory) by opening a terminal window and typing:
Code:
find /path/ -type l -exec rm -f {} \;
(note that there is a space between {} and \; )

I don't know what the path would be for a second Mac HD, as I don't have one... but the "mount" command should provide clues.

Hope this helps!

Thanks! I'd forgotten, but I'd used a similar command before to remove certain small files. No trouble with the path [/Volumes/backup/]
macgruder is offline   Reply With Quote
Old 08-12-2003, 02:15 AM   #5
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,941
file alias != symbolic link

Quote:
Originally posted by robophilosopher
If, as I understand it, Mac OS X aliases are UNIX-style symlinks, ...

Ah - but they aren't! Mac OS aliases are conceptually like sym-links but they are implemented completely independently.
See overview in Apple Developer Doc

Hence, as Merv has already explained, you can't detect them with ' type l' in 'find'.

Last edited by hayne; 08-12-2003 at 02:20 AM.
hayne is offline   Reply With Quote
Old 06-03-2012, 02:17 PM   #6
aitte
Prospect
 
Join Date: May 2012
Posts: 5
I'll bump this old thread by saying how to do it from the terminal (Spotlight MUST be enabled on the drive and any folders/paths excluded from Spotlight will NOT be covered):

mdfind "kMDItemKind == 'Alias'" -onlyin ~/Desktop

You can use any valid unix path for -onlyin to limit search to subfolders of that path, or remove the command to search every drive that spotlight indexes.

Note:

mdfind "kMDItemKind == 'Alias'" -onlyin /
mdfind "kMDItemKind == 'Alias'"

Are NOT equivalent.

The first one ONLY searches the root drive.
The second one searches EVERY indexed drive/volume in the computer.
aitte is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 08:50 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.