Created
November 21, 2012 22:32
-
-
Save jesperronn/4128294 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Save this as a .scpt file and put it in ~/Library/Workflows/Applications/Folder\ Actions folder. | |
#Next, right click the /Volumes folder and select Services -> Folder Action Setup and attach the script you just created | |
#AutoMagic! | |
#see http://www.jbmurphy.com/2011/07/15/os-x-running-a-script-when-a-usb-drive-is-inserted/ | |
FOLDER=~/Library/Workflows/Applications/Folder\ Actions/ | |
FILE=run_script_when_disk_insert.scpt | |
mkdir -p "$FOLDER" | |
rm "${FOLDER}${FILE}" | |
cat<<EOF >>"${FOLDER}${FILE}" | |
on adding folder items to this_folder after receiving these_items | |
repeat with current_item in these_items | |
try | |
do shell script POSIX path of current_item & ".OnInsert.sh" | |
end try | |
end repeat | |
end adding folder items to | |
EOF | |
cat<<HELPTEXT | |
Created ${FOLDER}${FILE} | |
Next, right click the /Volumes folder and select Services -> Folder Action Setup and attach the script you just created | |
AutoMagic | |
REMEMBER to create a file on disk named ".OnInsert.sh" | |
HELPTEXT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment