Hi,
Try this script :
----------------------------
setsourceFoldertochoose folder
tell application "System Events"
{name, name extension} of (filesofsourceFolderwhosename extensionisnot "zip")
mycompress2FilesSameName(theresult, sourceFolderasstring)
repeatwithiin (getfoldersofsourceFolder) --check in subfolders
{name, name extension} of (filesofiwhosename extensionisnot "zip")
mycompress2FilesSameName(theresult, pathofi)
endrepeat
endtell
oncompress2FilesSameName(tList, tFolder)
set tnames to item 1 of tList
settExtensionstoitem 2 oftList
set tc to count tnames
set j to 1
repeat while j < tc
tell (item j of tExtensions) to if it is not missing value or it is not "" then
set n1 to (count) + 2
else
set n1 to 1
end if
tell (item (j + 1) of tExtensions) to if it is not missing value or it is not "" then
set n2 to (count) + 2
else
set n2 to 1
end if
set name1 to item j of tnames
set name2 to item (j + 1) of tnames
if (text 1 thru -n1 of name1) = (text 1 thru -n2 of name2) then -- same name
set tFile1 to quoted form of POSIX path of (tFolder & name1)
set tFile2 to quoted form of POSIX path of (tFolder & name2)
set zipFile to quoted form of POSIX path of (tFolder & (text 1 thru -n1 of name1) & ".zip")
do shell script "/usr/bin/zip -j " & zipFile & " " & tFile1 & " " & tFile2
set j to j + 2
else
set j to j + 1
end if
endrepeat
endcompress2FilesSameName
----------------------------
if an archive already exists with the same name (in the parent folder of the files to compress) , the ZIP command overwrite this ".zip" file.
Example with "song 1.jpg", "song 1.mp3" and "song 1.zip" :
If "song 1.zip" doesn't exist, the ZIP command create the "song 1.zip" file.
If "song 1.zip" exist, the ZIP command overwrite the "song 1.zip" file (it will not create a new archive).