Using launchd with AppleScript to Access a Flash Drive Automatically..


I found the above great thread and I am trying to run this script and I get the following error message.

Syntax Erro Expected end of line, etc. but found a real number

I thought adding a “Tell Application Finder” would do it but id doesn’t. Can someone tell me why ?

With regards!


<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// [url="]]"][/url] <plist version="1.0"]
<string>Runs Applescript directly when Volumes Path changes</string>


you posted the content of the property list file in ~/Library/LaunchAgents,
but the error occurred in the triggered script.

Hello Stefan,

Thanks for your reply. Unfortunately, I am in a position where I do not understand what this code is doing.

I’ve thought the code is used to create a plist file with “Key”, “Type”, “Value”…

At this moment nothing is happening, I’ve added the code in the AppleScript editor. When I click the compile button nothing happen, I only get the error message which tells me there are elements that I am missing to run this code as AppleScript program.

I am sorry, unfortunately I am lost.

At this moment I am using the application “Do Something When”. This application has been good to me, however I require something more personalized.

I do have many Access Flash Drive which all have a name started with the prefix “PZV” followed by a number. For example : PZV0001, PZV0002, PZV0003…

I need to perform some actions when a flash drive starting with “PZV” is mounted on my computer. The number 0001, 0002, 0003 correspond to an order number for which I would perform some operations.

When I read the information found in the thread I thought this is what I needed. Am I right to think this thread would be helpful to me?

Best regards!


Yes, launchd can do what you’re looking for
The code is not AppleScript source code, it’s a property list.
Put the code in a TextEdit and save it with UTF8 encoding in ~/Library/LaunchAgents/WatchingVolumesPath.plist
Omit these two lines, because the launchctl -w command doesn’t set the disabled key to false automatically since 10.6

then load the agent in Terminal with

launchctl load -w ~/Library/LaunchAgents/WatchingVolumesPath.plist

In the Applescript you need a property flashState and the handling of the property for each drive

Sorry to go off topic. Can anyone recommend a book that details this process? I see the original thread references Unix for Mac OS X 10.4 Tiger but I can’t find an updated version for a more recent OS. Thanks.