Re: DropStuff workaround (was Re: OS X and RegEx Commands)
Re: DropStuff workaround (was Re: OS X and RegEx Commands)
- Subject: Re: DropStuff workaround (was Re: OS X and RegEx Commands)
- From: Graff <email@hidden>
- Date: Sat, 27 Dec 2003 15:42:42 -0500
Couldn't you just use the -srcfolder option? From the man page for
hdiutil:
-srcfolder directory
specifies the image size based on the
contents of
directory. -srcfolder also specifies that
the con-
tents of directory should populate the
resulting
image. -srcfolder copies file by file,
creating an
optimized filesystem on the destination image
(which then could be restored by asr(8)).
-srcdir
is a synonym for -srcfolder.
The default is to create a UDZO file. This has zlib compression built
in to it so you shouldn't need to zip the dmg to save space. You don't
even need to specify a file extension, the proper one will be filled in
for you.
The script would then be:
-------------
set myRecord to (display dialog "Enter a name for your archive : "
default answer "")
set archiveName to text returned of myRecord
set button to button returned of myRecord
set selectedFile to choose file
tell application "Finder"
update selectedFile
end tell
if archiveName is not "" and button is not false then
try
set filePath to quoted form of (POSIX path of selectedFile)
set dmgPath to quoted form of ((POSIX path of (path to desktop
folder)) & archiveName)
set archiveName to quoted form of archiveName
set theCommand to "hdiutil create -srcfolder " & filePath & " -fs
HFS+ -volname " & archiveName & " " & dmgPath
do shell script theCommand with administrator privileges
on error errmsg
display dialog errmsg
end try
end if
-------------
I couldn't figure out why it needed administrator privileges but I
couldn't execute the hdiutil command without it, both from the Terminal
and from the script. If anyone can get rid of that part it might be a
good thing. Otherwise this works just fine.
- Ken
On Dec 27, 2003, at 8:20 AM, John Cochrane wrote:
The code I wrote earlier was very rushed and full of errors.
Below is a script to create a disk image and then gzip it onto the
desktop.
It is a variation on a script by Jean-Baptiste LE STANG
Watch out for line breaks.
set myRecord to (display dialog "Enter a name for your archive : "
default answer "")
set archiveName to text returned of myRecord
set button to button returned of myRecord
set selectedFile to choose file
tell application "Finder"
update selectedFile
end tell
set totalSize to size of (get info for (selectedFile as alias))
set archiveSize to (round 1.25 * totalSize / (1024 * 1024))
if archiveSize < 5 then set archiveSize to 5
if archiveName is not "" and button is not false then
my createDiskImage(archiveName, selectedFile, archiveSize)
end if
on createDiskImage(thisName, theFile, totalSize)
try
set filePath to POSIX path of theFile
set dmgPath to POSIX path of (path to temporary items) & thisName &
".dmg"
do shell script "hdiutil create -size " & totalSize & "m -fs HFS+
-volname " & thisName & " " & quoted form of dmgPath
do shell script "hdiutil mount " & quoted form of dmgPath
do shell script "ditto -rsrcFork " & quoted form of filePath & "
/Volumes/" & thisName
do shell script "hdiutil unmount /Volumes/" & thisName
do shell script "gzip -c " & quoted form of dmgPath & " >
~/Desktop/" & thisName & ".tgz"
on error errmsg
display dialog errmsg
end try
end createDiskImage
John
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.