Jump to content

mount/unmount ipod script


Suzuka
 Share

3 posts in this topic

Recommended Posts

Im working on a script that will mount or unmount a drive depending on if its mounted or not, so far I have this,

 

tell application "Finder"

if exists folder "/Volumes/Advent iPod" = false then 
diskutil mount "/dev/disk2s3"

else if exists folder "/Volumes/Advent iPod" = true then 
diskutil unmount "/Volumes/Advent iPod"
end if
end tell

 

however, when I run it, I get a Syntax error

Expected “then”, etc. but found “.

 

it then highlights the " in the line

if exists folder "/Volumes/Advent iPod" = false then

 

what am I doing wrong, I'm not very experienced in applescripts

Link to comment
Share on other sites

Im working on a script that will mount or unmount a drive depending on if its mounted or not, so far I have this,

 

tell application "Finder"

if exists folder "/Volumes/Advent iPod" = false then 
diskutil mount "/dev/disk2s3"

else if exists folder "/Volumes/Advent iPod" = true then 
diskutil unmount "/Volumes/Advent iPod"
end if
end tell

 

however, when I run it, I get a Syntax error

it then highlights the " in the line

if exists folder "/Volumes/Advent iPod" = false then

 

what am I doing wrong, I'm not very experienced in applescripts

 

You could try something like:

 

set x to "0"
try
do shell script "ls '/Volumes/Advent iPod'"
on error
set x to "1"
end try
if x = "0" then
do shell script "disktool -u disk2s3"
else if x = "1" then
do shell script "disktool -m disk2s3"
end if

 

Just save it as an applescript app and run it. If the ipod is mounted it will unmount it and quit the app, if it is not mounted it will mount it and then quit.

Link to comment
Share on other sites

  • 6 months later...
 Share

×
×
  • Create New...