Making a zip file

Hi all
I’ve made this script for compressed file in zip format

on open these_items
	try
		repeat with i from 1 to number of items in these_items
			set this_item to item i of these_items
			do shell script "zip -jmT ad " & quoted form of POSIX path of this_item
		end repeat
	on error e
		display dialog e
	end try
end open

This AS works fine but it creates the “ad.zip” archivies on root folder instead the file’s folder (for example, if the file “abc.rtf” is on destop, I need to have the ad.zip file in desktop too).
Certanly, I can use move command, but there not so secure I think.

Thanks a lot

hi 18,

something like this i think:

on open these_items
	try
		repeat with i from 1 to number of items in these_items
			set this_item to item i of these_items
			set this_folder to (do shell script "dirname " & quoted form of POSIX path of this_item)
			do shell script "cd " & this_folder
			do shell script "zip -jmT ad " & quoted form of POSIX path of this_item
		end repeat
	on error e
		display dialog e
	end try
end open

there may be a shorter way, but does that work for you? i’m changing directory into the parent folder of this_item. you could also cd somewhere else if you’d prefer.

cheers.

Thats perfect. Tnx a lot!