Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Automator Service to toggle the alias bit System 10.9
Aliases in OS X are identified to the system by an attribute referred to as the alias bit. This hint provides a very simple way to be able to toggle the alias bit of selected files within the Finder.

There may be some need to be able to toggle the alias bit of files from within the Finder. For example, I found that using Bittorrent Sync to keep files synchronized across multiple devices is very useful and a real time saver, but suffers from a bug in the OS X version, that causes aliases to lose their status as aliases. I traced the problem to the alias bit not syncing and though the developers continue to promise to fix it, I got tired of waiting.

So I put together an Automator action that installs as a service in OS X. It adds a Service to the contextual menu that will toggle the alias bit on any file or folder in the Finder. It works on multiple files at once. Just select what you want, right click, and choose 'Toggle Alias Bit.' I made it a toggler rather than a setter so you can undo it if you accidentally turn a regular file into an alias.

I'm hosting it via my Google Drive if you want to download it.

To install, unzip it, double click it, done (sort of). If you don't have Xcode installed, the first time you try to use it there will be a short pause, then you'll be prompted to download and install Xcode developer tools. This will happen automatically, you just need to OK it. The reason for the developer tools requirement is the use of the GetFileInfo and SetFile commands, which are part of that.

If you want to do it yourself in Automator, here are the relevant steps:
  • Open Automator and choose Service as the type of new document.
  • Drag Run Shell Script to the workflow. Make sure the Service receives selected files or folder in Finder, are checked for the options. Shell should be /bin/bash and pass input as arguments
  • Copy and paste the following into the 'Run Shell script' box:
    #This script will toggle the alias bit for a file  
    
    for f in "$@"  
    do  
    
    #GetFileInfo -aa should return 1 for alias, 0 for not alias  
    
        if [ `GetFileInfo -aa "$@"` == "1" ] # if it's an alias  
        then  
          SetFile -a "a" "$@" # set it to not be an alias  
        else  
          SetFile -a "A" "$@" # otherwise, it's not an alias, so make it one  
    
        fi  
    
    done
    
  • Save it as something useful like 'Toggle Alias bit.'
  • Use as described above.
Apologies if this is not the most simple or efficient scripting. It is the first bit of programming I have done in about twenty years. Also, this will likely work in older versions of OS X, but how far back, I do not know.

[crarko adds: I haven't fully tested this one. I had some problems working with the downloadable version, so I'd recommend creating the Service from scratch using the code above. I already have Xcode installed so I did not get the prompt to install it, as expected.]
    •    
  • Currently 1.12 / 5
  You rated: 1 / 5 (100 votes cast)
 
[7,005 views]  

Automator Service to toggle the alias bit | 2 comments | Create New Account
Click here to return to the 'Automator Service to toggle the alias bit' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automator Service to toggle the alias bit
Authored by: CHM on Apr 29, '14 12:57:53PM

Commenting on my own hint: I submitted this months ago maybe? At least one month. Since then Bittorrent Sync has been updated to fix the alias bit issue, finally. This hint might still be useful to someone though.

Also, go easy on me, I've done zero programming in the last 20 years prior to this script.



[ Reply to This | # ]
Automator Service to toggle the alias bit
Authored by: crarko on Apr 30, '14 04:06:39AM

Yes, I'm going back in the queue a bit now.

Thanks for the update.



[ Reply to This | # ]