If you work with file permissions a lot, then you know how crazy it can get when you need to change a ton of files to their correct permission types. With this AppleScript folder action, you can easily change the permissions just by dragging and dropping files in their correct folder.
Creating the Script
To get started, we'll open the Script Editor (located in /Applications/Utilities). Once you have the editor opened, copy/paste the following script:
on adding folder items to this_folder after receiving added_itemsThis script will change the dropped files to a permission of "0644" meaning that everyone can read the file. For information about chmod and command line permissions strings, visit the Wikipedia page.
tell application "Finder"
set fold_name to the name of this_folder
repeat with i from 1 to number of items in added_items
set new_item to item i of added_items
set the item_path to the quoted form of the POSIX path of new_item
do shell script ("/bin/chmod -R +r " & item_path)
end adding folder items to
Continue reading to learn more about this AppleScript and folder actions.
Saving the Script
To save your AppleScript and get it ready to attach to a folder, select File > Save. Type in a file name of your choosing, then select "Script" from the File Format drop-down box. Remember your save location, and click Save.
Attaching the Script
There are two good options that you can choose between for attaching your script to the folder. First solution is simple: If you want the script to show up in the regular Folder Actions Setup utility, then you will need to place your .scpt file in the /Library/Scripts/Folder Action Scripts/ directory. You will then see the script show up in the pop-up dialog when you setup your folder (as described in part one of the folder actions feature).
Additionally, you can right-click on your folder and select More > Attach a Folder Action. From the pop-up dialog, you will have the ability to select your custom .scpt file and have it attached to the selected folder.
Running the Script
To start your custom script, just drag and drop files that you want to be "chmodded" to the folder ... they will be magically transformed.
Almost any AppleScript can be converted into a folder action. A great place to start looking for folder action ideas is the /Applications/AppleScript/Example Scripts folder. There are a ton of examples for you to look at in this folder.