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

A Folder Action Script to auto-set the Execute bit UNIX
This is a simple Folder Action Script that will set the executable bit on any file saved within the folder to which the script is attached. Copy and paste the following into a Script Editor document, and save it as a script into your Folder Action Scripts directory.
on adding folder items to thisFolder after receiving theItem
  set fileName to POSIX path of theItem
  do shell script "chmod +x " & fileName
end adding folder items to
Remember to call your shell (#!/bin/bash) or application (#!/usr/local/bin/ruby -w) in the first line of your script. Then save to, or drag your file to, the folder with the action script attached.
    •    
  • Currently 3.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[8,545 views]  

A Folder Action Script to auto-set the Execute bit | 2 comments | Create New Account
Click here to return to the 'A Folder Action Script to auto-set the Execute bit' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A Folder Action Script to auto-set the Execute bit
Authored by: dhrakar on May 03, '07 09:18:12AM

Just in case you decide to drop a folder or an application into this folder, it would be better to have chmod run recursively:

do shell script "chmod -R +rX " & fileName

The capital 'X' tells chmod to only add the execute bit to things that it is appropriate for (such as subfolders) and not to data files. It comes in really handy if you are trying to recursively add, say, group permissions to a subdirectory. If chmod -R g+rX sees that a file already has owner execute, it will add both group read and group execute. Otherwise, it will only add group read.



[ Reply to This | # ]
A Folder Action Script to auto-set the Execute bit
Authored by: craigw on May 03, '07 06:16:56PM

I like this tip! I'm going to set it up for ~/bin.
Also, both Smultron & Textmate have menu items to make the current document executable.

Correct me if I'm wrong, but I don't think this is right:
do shell script "chmod -R +rX " & fileName
The point of the hint being, to make files executable that aren't already.

Also, I would do it more like this:
chmod -R u+x
I don't want a whole folder of files that are executable by anybody & everybody.



[ Reply to This | # ]