Re: hdiutil (suppress license agreemet)
Re: hdiutil (suppress license agreemet)
- Subject: Re: hdiutil (suppress license agreemet)
- From: Laine Lee <email@hidden>
- Date: Sun, 06 Apr 2008 20:42:29 -0500
- Thread-topic: hdiutil (suppress license agreemet)
Title: Re: hdiutil (suppress license agreemet)
On 4/6/08 2:22 AM, "Laine Lee" <email@hidden> wrote:
> On 1/22/08 3:50 PM, "Andrew Thomson" <email@hidden> wrote:
>
>> While I'm sure I could copy the necessary applications into a newly created
>> disk image without an associated license agreement, I'd rather find a way to
>> accommodate this type of disk image.
>
> Here's what I use.
>
I really threw out the baby with the bathwater in my first attempt to send a clean, generic version of my script. Here’s the correct script. It runs as a droplet or not. If the resulting file already exists (if the script has been successfully used once on a given disk image), it does not warn before overwriting that disk image on subsequent runs. It does not overwrite the input disk image (the original).
-----
property temppath : "/private/tmp/"
on open the_items
my build_archive(the_items)
end open
on build_archive(the_items)
repeat with the_item in the_items
set the_item to the_item as alias
try
tell application "Finder"
set sost to ((container of file (the_item as string)) as alias) as string
end tell
set sost to POSIX path of sost
on error therrr
log therrr
display dialog therrr
set sost to "/Volumes/"
end try
set this_filepath to (the_item as string)
if last character of this_filepath is ":" then
tell me to set it_is_a_folder to true
else
set it_is_a_folder to false
end if
if not it_is_a_folder then
set thesourcename to (name of (info for the_item))
set the_source_file to POSIX path of this_filepath
set pos_filepath to sost
set thesourcename to replace_chars(thesourcename, " ", "_")
set dest_file to (quoted form of (temppath & thesourcename))
set tempname to ((characters 1 thru -5 of thesourcename) & "temp")
try
set my_command to "hdiutil convert -format UDRW" & space & (quoted form of the_source_file) & space & "-o" & space & (quoted form of (temppath & tempname))
do shell script my_command
set my_2nd_command to "hdiutil convert" & space & (quoted form of (temppath & tempname & ".dmg")) & space & "-format UDZO -imagekey zlib-level=9 -o" & space & (quoted form of (temppath & thesourcename))
do shell script my_2nd_command
do shell script "rm" & space & (quoted form of (temppath & tempname & ".dmg"))
on error onerr
activate
display dialog onerr
end try
if pos_filepath is "/Volumes/" then
set pos_filepath to (POSIX path of (path to desktop folder))
end if
set targdetect to (pos_filepath & thesourcename)
set name_target to alias (POSIX file targdetect)
set finishname to "_recomp"
--use this instead of above to overwrite your original disk image: set finishname to ""
set thesourcename to (((characters 1 thru -5 of thesourcename) & finishname) as Unicode text)
tell me to do shell script "ditto -rsrcFork" & space & dest_file & space & "\"" & (pos_filepath & thesourcename) & ".dmg" & "\""
end if
try
do shell script "rm" & space & dest_file
end try
end repeat
end build_archive
on replace_chars(this_text, _bad, _good)
set AppleScript's text item delimiters to the _bad
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the _good as string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
on run
set the_items to (choose file with prompt "Choose the disk image (.dmg) file you want to duplicate...") as list
build_archive(the_items)
end run
-----
--
Laine Lee
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden