Check if dropped item is a zip file

Guys,
I have coded an app where a user can either choose or drop a folder for processing. Now sometimes the folder can be zipped. I want the app to check if the dropped item is a zip file or not. If it is a zip file, unzip and then process the folder contents. So, basically if the file named “myFolder.zip” is dropped on the app, it should be unzipped and the resulting folder “myFolder” should be processed.

This is how far I have gotten:

on open the_bundle
	set typeF to info for the_bundle without size
		set theFileKind to kind of typeF
		if theFileKind is equal to "ZIP Archive" then
			display dialog theFileKind
-- unzip this file
-- get the folder and use it for processing
		end if

	
end open

[EDIT]: I got it to where I can test if the dropped item is a zip file or not. How do I unzip the file and get the folder for further processing

See the man page for zip – you can unzip a file with it as a “do shell script …”

yeah I figured it out. :slight_smile:

CAUTION

the kind property is localized so when used in an English system, kind is “Zip archive” but on a French one, it is “Archive dans un fichier ZIP”
There is a better test which isn’t localization dependent :


set typeF to info for the_bundle without size
set theFileID to type identifier of typeF
if theFileIDis is equal to "public.zip-archive" then
	display dialog theFileID
end if

Yvan KOENIG (VALLAURIS, France) mercredi 25 mai 2011 16:34:50