# Automator Script for External USB Drive



## jcabaleiro (Jan 4, 2007)

Is there an automator script to check if an external USB drive is connected?  I want to be able to run a program only if it is...

Joe


----------



## barhar (Jan 4, 2007)

'Is there an automator script to check if an external USB drive is connected?' - I do not know of any.

However, one could add the following code ...

set tDisk to "USB20FD" -- Name of disk to check for.

tell application "Finder" to if ((name of disks) contains tDisk) then
	say tDisk & " exists"
else
	say "That disk does not exist"
end if

... into 'Script Editor' ('/Applications/AppleScript/' folder) and save (the code) as an 'application'.

If an 'Automator' workflow application is desired, then launch (open, run) 'Automator', and double click on the 'Automator' 'Library's 'Run AppleScript' 'Action'. When the 'Run AppleScript' actions' window appears (in the right side panel) - replace '(* your script goes here *) with the code provided above.

-----

The difference between a 'Script Editor' 'applet' verses an 'Automator' 'workflow application' is the resultant applications' size. With respect to the above code - the 'applet' is 60 KB, and the 'workflow application' is 228 KB.


----------

