Re: compress with resource forks
Re: compress with resource forks
- Subject: Re: compress with resource forks
- From: Jean-Baptiste LE STANG <email@hidden>
- Date: Tue, 5 Aug 2003 10:43:28 +0200
What I do is enclosing all the files I want to compress in a disk
image, and then I use gnutar/tar/gnuzip to compress the disk image
Here is my script (requires Satimage OSAX), YOu just have to select the
files you want to compress (they must be in the same directory)
The script, is not yet finished but it works
@+ JB
tell application "Finder"
activate
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 selectedFiles to navchoose object
set totalSize to 0
repeat with x in selectedFiles
set totalSize to totalSize + (size of (get info for (x as alias)))
end repeat
set archiveSize to (round 1.25 * totalSize / (1024 * 1024)) --125 % of
the original size
if archiveSize < 5 then set archiveSize to 5
if archiveName is not "" and button is not false then
my createDiskImage(archiveName, selectedFiles, archiveSize)
end if
display dialog "Archive created"
end tell
on createDiskImage(thisName, thooseFiles, totalSize)
try
set AppleScript's text item delimiters to ""
set myCommand to "hdiutil create -size " & totalSize & "m
~/Desktop/" & thisName
do shell script myCommand
do shell script "hdid -nomount ~/Desktop/" & thisName & ".dmg"
set diskList to paragraphs of (do shell script "ls /dev/ | grep
'disk' | awk '{print $1}'")
set itemCount to count diskList
set myDiskName to item (itemCount - 2) of diskList
set myCommand to "newfs_hfs -v " & thisName & " /dev/" & myDiskName
do shell script myCommand
set diskname to getRealDisk(myDiskName)
set myCommand to "hdiutil detach " & diskname
do shell script myCommand
set myCommand to "hdid ~/Desktop/" & thisName & ".dmg"
do shell script myCommand
repeat with x in thooseFiles
tell application "Finder"
set currentDirectory to quoted form of POSIX path of ((container of
(x as alias)) as alias)
set fileName to (name of (x as alias))
end tell
set myCommand to "cd " & currentDirectory & ";" &
"/Developer/Tools/CpMac -r -p '" & fileName & "' /Volumes/" & thisName
do shell script myCommand
end repeat
set myCommand to "hdiutil detach " & diskname
do shell script myCommand
set myCommand to "gzip -c ~/Desktop/" & thisName & ".dmg >
~/Desktop/" & thisName & ".tgz"
do shell script myCommand
on error errmsg
display dialog errmsg
end try
end createDiskImage
on getRealDisk(thisDisk)
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "r"
set realDiskName to text item 2 of thisDisk
set AppleScript's text item delimiters to "s2"
set realDiskName to text item 1 of realDiskName
set AppleScript's text item delimiters to oldTID
return realDiskName
end getRealDisk
Le mardi, 5 ao{ 2003, ` 09:32 Europe/Paris, John Cochrane a icrit :
On Tuesday, August 5, 2003, at 04:35 PM, John C. Welch wrote:
On 08/04/2003 19:07, "email@hidden"
<email@hidden>
wrote:
tell application "terminal"
if the glove don't fit
you must aquit
end if
end tell
I think more along the lines of
If glove (not fit) then
set acquit to true
End if
john
:-)
Then has the jury spoken ?
property compressWithResourceForks: false
John Cochrane
(now considering a nom de plume)
_______________________________________________
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.