Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Batch processing zip files w/ Automater

ex: I want to select 30 files and compress them into 30 seperate zip files.


I found this apple script but I cannot get it to work in lion...


Could someone break this down for a cluless user (me) who only knows how to cut and paste into the applescript editor?


originaly posted by red_menace on Apr 20, 2008 2:46 PM


<pre style="

font-family: Monaco, 'Courier New', Courier, monospace;

font-size: 10px;

margin: 0px;

padding: 5px;

border: 1px solid #000000;

width: 720px; height: 335px;

color: #000000;

background-color: #FFDDFF;

overflow: auto;"

title="this text can be pasted into an Automator 'Run AppleScript' action">

on run {input, parameters}

-- create a PKZip archive of the selected Finder item(s)

-- if no destination folder is specified, the archive will be placed in the same location

-- input: a list of Finder items to archive

-- output: a list of Finder items archived


set output to {}

set SkippedItems to {} -- this will be a list of skipped items

set DestinationFolder to missing value -- a Finder path to a destination folder if different


repeat with SomeItem in the input -- step through each item 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 -- save the archive to the same location

set ArchiveName to ArchiveSource & ".zip"

else -- save the archive to the specified folder

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 -- handle skipped items

set TheCount to (count SkippedItems) as text

display alert "Error with Archive action" message TheCount & " items(s) were skipped - workflow will continue"

(*

choose from list SkippedItems with title "Error with Archive action" with prompt "The following items were skipped:" with empty selection allowed

if result is false then error number -128 -- user cancelled

*)

end if


return the output -- pass the result(s) to the next action

end run

</pre>



Thanks!

Posted on Mar 24, 2012 1:09 PM

Reply
4 replies

Batch processing zip files w/ Automater

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.