Re: guess the file size of compressed file from the original
Re: guess the file size of compressed file from the original
- Subject: Re: guess the file size of compressed file from the original
- From: Graff <email@hidden>
- Date: Sun, 27 Jun 2004 00:34:09 -0400
Whups, I forgot a "quoted form of" in there so it would fail on certain
folder names. Here's the corrected script:
----
set theFolder to choose folder
set posixFolder to quoted form of POSIX path of theFolder
set theName to name of (info for theFolder)
set tmpFolder to POSIX path of (path to "temp")
set tmpFile to quoted form of (tmpFolder & "tempArchive.dmg")
set dstPath to quoted form of ((POSIX path of (path to desktop folder))
& theName)
do shell script "/usr/bin/hdiutil create -ov -imagekey zlib-level=9
-srcfolder " & posixFolder & " -volname " & quoted form of (theName) &
" " & tmpFile
do shell script "/usr/bin/hdiutil segment -o " & dstPath & "
-segmentSize 5m " & tmpFile
----
- Ken
On Jun 26, 2004, at 11:38 PM, Graff wrote:
On Jun 26, 2004, at 10:24 PM, Bill wrote:
What is the eventual purpose of doing this? Will you need to be
able to open each zip file individually or are you splitting them up
and then planning to re-join them before un-archiving them?
Well, let's start from the purpose: using Gmail as an "alternative
backup". Currently, I used a script to zip every file of a chosen
folder, then send them out as email attachment. Each email subject is
the path (Mac style) of the file, body is the backup time.
At this moment, I need to avoid file bigger than 5MB, pick them out
by hand, because my ISP limits each email must be smaller than 5MB.
My experience of Gmail is that their search engine is excellent ;)
Using file name or subfolder name, I get what I want to find.
Inspired by your idea, I'm thinking of making disk image of big file,
split it into 5MB segment, zip the segment. For small file, just zip
it. Or, to make disk image from the chosen folder, split it into 5MB
segment, and set the body of email to list of items contained.
No need to zip the segmented dmg. The shell tool hdiutil will
compress it for you. You don't even need to pull the files out
seperately, you can take a folder and put it straight into a dmg file
with hdiutil. There is also no need to just zip a small file, the dmg
file will never be much larger than the file and the file won't
segment if its below the segment size. The disk image solution should
handle all of these cases by itself.
Here's a little bit of code that takes the folder, puts it into a dmg,
compresses it to the maximum amount, segments it to the desktop and
then clears out the temporary file needed for the dmg creation:
----
set theFolder to choose folder
set posixFolder to quoted form of POSIX path of theFolder
set theName to name of (info for theFolder)
set tmpFolder to POSIX path of (path to "temp")
set tmpFile to quoted form of (tmpFolder & "tempArchive.dmg")
set dstPath to quoted form of ((POSIX path of (path to desktop
folder)) & theName)
do shell script "/usr/bin/hdiutil create -ov -imagekey zlib-level=9
-srcfolder " & posixFolder & " -volname " & theName & " " & tmpFile
do shell script "/usr/bin/hdiutil segment -o " & dstPath & "
-segmentSize 5m " & tmpFile
do shell script "rm -f " & tmpFile
----
The segmented files will be named for the folder they came from and
the names will go like foldername.dmg, foldername.002.dmgpart,
foldername.003.dmgpart, and so on.
Once it creates the segments all you need to do to open the segmented
dmg file is to have all the segments in one place and then open the
first dmg - the one without a number and which ends in .dmg instead of
.dmgpart.
_______________________________________________
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.