Hi everyone
Complete applescript newbie here. I was hoping you could help me out.
Im creating an applescriptobjc app in xcode to backup some files to to a USB stick that has an encrypted .dmg file on it. What I want it to do is mount the image copy the files unmount the image and unmount the USB stick.
What I’ve got so far is this:
script Server_BackupAppDelegate
property parent : class "NSObject"
on clickedUSB_(sender)
try
tell application "Finder"
set imageFile to POSIX path of (file "Secure Disk.dmg" of disk "Genie Backup" as alias)
end tell
on error
display alert "Cannot find the backup destination. Please insert USB stick and try again."
return
end try
tell application "System Preferences" to quit
if ((imageFile as string) ends with ".dmg") then
do shell script "/bin/bash hdiutil mount \"" & ¬
POSIX path of (imageFile as string) & "\""
end if
repeat with aFile in genieFiles
tell application "Finder" to duplicate file (aFile as alias) to disk "Secure Disk" with replacing
end repeat
tell application "Finder"
eject disk "Secure Disk"
eject disk "Genie Backup"
end tell
tell application "System Preferences" to launch
display alert "Backup Complete. Safe to now remove USB"
end clickedUSB_
on applicationWillFinishLaunching_(aNotification)
set genieFiles to {":Users:user:Desktop:Genie:Genie 3.rtf", ¬
":Users:user:Desktop:Genie:Genie 1.rtf", ¬
"Users:user:Desktop:Genie:Genie 2.rtf"}
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
end script
I initially created this script in AppleScript editor and then transferred it to xcode putting in the appropriate objc parts. It runs beautifully in Applescript editor but as soon as I try to run it in xcode it gets up to the do shell script and either does nothing or hangs and I have to terminate the process via xcode.
Any ideas on how to get this working in xcode?
Model: MacBook
AppleScript: Xcode 3.2.1
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)