Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to mount, run, unmount a disk image' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to mount, run, unmount a disk image
Authored by: oshea on Oct 08, '04 11:08:36PM
It doesn't look like the script will unmount correctly if the mounted image name contains a space. The first 'hdiutil unmount...' fails because it thinks you're trying to pass it two different image names.

Any idea what the proper syntax is to work around this?

Relevant bits:
 property diskname : "Nemo UWF"
 do shell script ("hdiutil unmount /Volumes/" & diskname & " -force")


[ Reply to This | # ]
An AppleScript to mount, run, unmount a disk image
Authored by: emendelson on Oct 10, '04 10:18:41AM

The solution to oshea's question seems to be something like this:

If you need to mount a disk image whose name in the Finder has a space or ampersand or other non-alphanumeric character, then you probably need to use two different variables instead of the one "diskname" variable in the original script.

The variable diskname should be the name in the Finder, as in the original script, and this should be used in the pure-Applescript parts of the script (the parts that don't use shell scripts).

Another variable would be called something like unixdiskname, and this would use escaped characters, like this:

unixdiskname: "Nemo\ UMF"

or

unixdiskname: "This\ \&\ That"

Then, in the original script's shell script commands, replace "diskname" with "unixdiskname". I haven't tested this enough to be certain it works, but I think it will.



[ Reply to This | # ]
An AppleScript to mount, run, unmount a disk image
Authored by: jbreazeale on May 09, '05 03:09:48AM
I tried your suggestion for escaping the spaces and ScriptEditor gave me an error. The script line:
    property unixdiskname : "Reader\ Rabbit\ Toddler"
was diagnosed with the error:
    Syntax Error
    Expected """ but found unknown token.
Could you (or somebody else) give me a way around this issue?

[ Reply to This | # ]