on run {input, parameters}

set output to {}
set SkippedItems to {}
set DestinationFolder to missing value

repeat with SomeItem in the input
try
set SomeItem to SomeItem as text
if the last character of SomeItem is in {":", "/"} then set SomeItem to text 1 thru -2 of SomeItem
set ArchiveSource to POSIX path of SomeItem
if DestinationFolder is missing value then
set ArchiveName to ArchiveSource & ".zip"
else
set TheName to name of (info for SomeItem as alias)
set ArchiveName to (POSIX path of DestinationFolder) & TheName & ".zip"
end if
do shell script "ditto -ck " & (quoted form of ArchiveSource) & space & (quoted form of ArchiveName)
set the end of the output to (POSIX file ArchiveName) as alias -- success
on error ErrorMessage number ErrorNumber
log ErrorMessage
set the end of SkippedItems to SomeItem
end try
end repeat

if SkippedItems is not {} then
set TheCount to (count SkippedItems) as text
display alert "압축 작업 중 오류가 발생했습니다." message TheCount & "개의 항목을 압축하지 못했습니다."
end if

return the output
end run
Report abuse