ZipIt

Could some please tell me how I could add a password to a .zip archive created by ZipIt. I’ve tried various combinations but can’t get it to work. Any suggestions greatly appreciated:

tell application "ZipIt"
			activate
			set the_window to (make new window at beginning)
			repeat with file_to_zip in filelist
				add file_to_zip to the_window
			end repeat
			compress the_window file zipFileName in zipFolder
			quit
		end tell

According to the dictionary, as part of the core suite:

filen: Compressed files within an archive
ELEMENTS
contained by folders, entries, documents, windows.
PROPERTIES
password (character) : The password to be used when decrypting or encrypting this file

Try this:

set zipfolder to (path to desktop)
set filelist to {alias "path:to:file1", alias "path:to:file2"}
set zipFileName to "cool.zip"

tell application "ZipIt"
	set the_window to (make new window at beginning)
	add filelist to the_window
	set password of entries of the_window to "secret"
	compress the_window name zipFileName in zipfolder
	close the_window
end tell

Thanks for that, this script works

set zipFolder to (path to desktop)
set filelist to {alias "Macintosh HD:Users:username:Desktop:file.pdf"}
set zipFileName to "cool.zip"

tell application "ZipIt"
	set the_window to (make new window at beginning)
	add filelist to the_window
	--set password of entries of the_window to "secret"
	compress the_window file zipFileName in zipFolder
	close the_window
end tell

However, if I uncomment the set password line I get the following error:

ZipIt got an error: Can’t set password of every entry of window 1 to “secret”.

If it makes it any easier, I only want to zip one file at a time, add a password (from Filemaker) and then loop through a file list
Cheers!!

Perhaps you’re using a different version? (mine is 2.2.2) Seems that you’re compiling “file zipFileName” where I do “name zipFileName”…

Try, then:

set password of files of the_window to "secret"
--> or
set password of first file of the_window to "secret"

Thanks for that - you’re quite correct, I was using 2.1 as there is a bug in 2.2 with SEAs. With 2.2 it works perfectly.
Thanks for your help!!

Isn’t there also a way to zip files with passwords at the command line? I’ve tried using zip -P but that doesn’t seem to work. It gives me an error message of “Encryption not supported”?

Next question… Is it possible to save the ZIP file as a self extracting archive with the password?
Thanks!!