Make a Mac alias from command line.

Discussion in 'Mac Programming' started by Big Dave, May 20, 2010.

  1. Big Dave macrumors 6502

    Joined:
    Nov 27, 2007
    Location:
    Crestview, Fl
    #1
    I would like to create aliases for all my movies on an external drive and have the alias in my Movies folder. I would like to avoid using finder and "command option". I tried to do ln-s but the alias doesn't work properly. I would like to do something like:
    $find / -name *.avi -exec ln -s {} ~/Movies \;

    Any help?
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Describe exactly what doesn't work.

    When I run a similar command on my machine, it works fine.
    Code:
    find ~ -name '*.mp3' -exec ln -s {} /Volumes/Work/mp3 \;
    
    I don't have any .avi's on this machine, but other than that, and the fact that I quoted the globbing pattern but you didn't, I see no reason why what you posted won't work.

    And the resulting symlinks all work fine.
     
  3. Big Dave thread starter macrumors 6502

    Joined:
    Nov 27, 2007
    Location:
    Crestview, Fl
    #3
    When I try to click the alias file I get:
    The alias “file.avi” can’t be opened because the original item can’t be found.
    This is a popup with options to fix alias, delete alias, or cancel.
     
  4. ChrisA macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #4
    Why not link the Movies directory. I don't see the need to make a billion links for each .avi file. The every time you added a now movie you'd need a new link. Much simpler to do this just once

    Code:
    cd
    mv Movies Movies.saveforawhile
    ln -s /some/volumename/Movies .
    This of course assume the name of the external disk a /some/volumename/ and that you have nothing inside the ~/Movies
     
  5. Big Dave thread starter macrumors 6502

    Joined:
    Nov 27, 2007
    Location:
    Crestview, Fl
    #5
    That is one way to approach it but my external disk where I have all of my movies is divided into subdirectories: /Volumes/Movies/some_movie/some_movie.avi

    I think I did this because some of the filenames are not obvious descriptors of what the actual movie is.

    I think aliasing the Movie folder is probably the best way to go.

    Next Question:
    Can I alias to a volume across a network?
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    Yes, in general. The remote volume needs to be mounted at the same mount-point as when the symlink was created.

    I just tried this with symlinks residing on my local machine, that refer to remote files on an AFP server, and they worked. The symlinks were created with a 'find' command.

    However, if the remote disk is unmounted (ejected) at the time I try to open them in Finder, then the symlinks fail with the same "fix or delete alias" dialog.

    If your symlinks don't work, it may be something else you're doing (or not doing). Please provide details of your configuration. Your Mac's OS version, your server's OS and version, what protocol you're connecting to it with, etc.

    If you don't know the protocol, then enter this single command in Terminal and press the RETURN key.
    Code:
    mount
    
    Post the output.

    It wouldn't hurt to post some of the output of this command:
    Code:
    ls -l ~/Movies/*.avi
    
    Include the output from the symlinks you created that refer to the remote avi files.

    The 'mount' output is so we can see what protocol the network disk is mounted with. The 'ls -l' output is to see what the symlinks actually point to, and whether that pathname is the same as what 'mount' said.
     
  7. Big Dave thread starter macrumors 6502

    Joined:
    Nov 27, 2007
    Location:
    Crestview, Fl
    #7
    Thanks for all the help. I'll try to work your earlier post regarding "mount" a little later. For now, I have found a solution for my problem. I downloaded a package called osxutils from:
    http://www.sveinbjorn.org/cljg2macosx

    There is a command mkalias. Using this command, I was able to make aliases of my files that open when I click them.

    -Dave
     

Share This Page