Scott reminded me the other day that Mac OS X has a nifty capability to attach scripts to folders, such that when you add a new item to the folder it runs the script. This is a very powerful capability when combined with Pando. Just put a folder action on your Pando Downloads folder, and you can have all sorts of cool things happen.
For example, this script will automatically add new audio and video files that you download into iTunes:
property extension_list : {"mp3", "m4a", "aac", "m4v", "mov", "mp4"}
on adding folder items to my_folder after receiving the_files
tell application "Finder"
set this_name to the name of my_folder
end tell
repeat with i from 1 to number of items in the_files
set this_item to (item i of the_files)
set the item_info to info for this_item
if the name extension of the item_info is in the extension_list then
tell application "iTunes"
try
set this_track to add this_item to playlist "Library" of source "Library"
duplicate this_track to user playlist "Pando Files"
end try
end tell
end if
end repeat
end adding folder items to
To install this script, save the attached Add to iTunes script to /Library/Scripts/Folder Action Scripts, then in Finder find your "Pando Packages" folder (or wherever you have configured Pando to download files), control-click (or right-click) on it, and select "Attach a Folder Action...", then pick AddToITunes.scpt.
For more information on Folder Actions and how to set them up, see AppleScript in Mac OS X: Folder Actions.
What cool things can you think of to do with Folder Actions? Post cool scripts (or links about AppleScripting) here!
| Attachment | Size |
|---|---|
| AddToITunes.scpt | 3.63 KB |
Hey Everybody, I thought I
Hey Everybody,
I thought I would recontribute a script that got started with some help from Scott and Laird. I originally asked them if they could implement an email notification system for when files have finished downloading. Scott then sent me a quick script to start with, and with some help from the MacSripter forum (well, pretty much they wrote the finished script since I JUST began my applescripting the other day), I came up with the script below.
First you need to add your email address to the script. So double-click the script, and when it opens put in your email address where it says "email@myemail.com".
You need to add this script into the Macintosh HD > Library > Scripts > Folder Action Scripts. Then you need to find your Pando downloads folder (usually under your home folder and called "Pando Packages" (I think)) and control-click it and "Enable folder actions". Then you control-click it again and choose "Add Folder Actions" and navigate to this script. This script will email you when your files are finished downloading, and it will tell you what the file is that has finished. Here is the script you can cut and paste:
(*This folder action watches the Pando downloads folder. For every completed file, it sends an email to the specified address to tell them the download is complete.
*)
on adding folder items to this_folder after receiving added_items
repeat with i in added_items
set {Nm, Ex} to {name, name extension} of (info for i)
if Ex is not "downloading" then
tell application "Mail"
set addrVar to "email@myemail.com"
set subjectvar to Nm & " download complete"
set alert_message to Nm & " has finished downloading. It has been added to folder " & name of (info for this_folder as alias) & "."
set composeMessage to make new outgoing message with properties {subject:subjectvar}
tell composeMessage
make new to recipient at beginning of to recipients with properties {address:addrVar}
set the content to alert_message
end tell
send composeMessage
end tell
end if
end repeat
end adding folder items to