• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Access to Zip
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Access to Zip


  • Subject: Re: Access to Zip
  • From: Adam Bell <email@hidden>
  • Date: Fri, 23 Jun 2006 19:07:59 -0300
  • Comment:

At 10:45 PM +0100 6/23/06, kai wrote:
On 22 Jun 2006, at 20:48, email@hidden wrote:

You can use the command line application unzip to do this.

do shell script "unzip 'path/to/file' "

That should do it. Here's a variation that unzips to the same location as the zipped file (and attempts to avoid messing with any items that might already exist in the same location):



Your script has an interesting side effect , Kai, if the zipped "file" is a folder containing folders. The original folder is, of course, restored as expected, but a new folder is created with it called: "__MACOSX" (two leading underscores) containing the now empty folders of the original but none of the files.


Adam


(* Caution: the last statement in the try block deletes the zip file without trashing it *)


to unzip_and_delete(z)
try
set p to quoted form of z's POSIX path
set n to paragraph 2 of (do shell script "zipinfo " & p)
set n to n's text ((offset of ":" in n) + 4) thru -(1 + ((n ends with "/") as integer))
set d to (do shell script "dirname " & p) & "/"
set f to d & n as POSIX file
tell application "Finder" to if f exists then error "The " & item f's class & " \"" & n & "\" already exists."
do shell script "unzip -q " & p & " -d " & quoted form of d
do shell script "rm " & p (* delete the zip file without trashing *)
on error e
display dialog e buttons {"Cancel"} default button 1
end try
end unzip_and_delete


unzip_and_delete(choose file of type "com.pkware.zip-archive" without invisibles)

----------------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Access to Zip
      • From: kai <email@hidden>
References: 
 >Access to Zip (From: Chilton Webb <email@hidden>)
 >Re: Access to Zip (From: email@hidden)
 >Re: Access to Zip (From: kai <email@hidden>)

  • Prev by Date: Re: Access to Zip
  • Next by Date: Re: Currency Numbers
  • Previous by thread: Re: Access to Zip
  • Next by thread: Re: Access to Zip
  • Index(es):
    • Date
    • Thread