I wrote this really quickly this morning to create zip files of a large amount of files I had in a folder that were needed to be compressed into individual zip files.
So, if a folder contains file1.txt, file2.txt, file3.txt you will get file1.zip, file2.zip, file3.zip respectively. The original files remain in tact for you to do what you wish with.
This script works with Leopard’s Archive Utility on OS X 10.5 or higher. It could easily be modified to use BOMArchiveHelper instead on Tiger systems for the same effect.
Just thought I would post it online in case someone would find it useful.
set processFolder to choose folder with prompt "Choose Folder containing files to individually archive:"
tell application "Finder" to set theFileList to (files of entire contents of processFolder) as alias list
repeat with theFile in theFileList
tell application "Finder" to open file (theFile as string) using path to application "Archive Utility"
end repeat
I tried @generica’s script on Catalina and found that it still works.
But when the folder contains Finder-alias files or ready-made cpgz (MAC)-archives, it throws error messages, which is quite understandable. Also, the repeat loop is optional here.
I’ve tweaked the script as best I could, but I’m guessing there’s more room for improvement. Anyway, here’s my version:
-- script: Create individual .cpgz (MAC)- archives for files of entire contents of folder
-- Written: by @generica, apapted: by KniazidisR
set processFolderAlias to choose folder with prompt "Choose Folder containing files to individually archive:"
createCPGZarchives(processFolderAlias)
on createCPGZarchives(processFolderAlias) -- alias parameter
set archiveUtilityID to "com.apple.archiveutility"
tell application "Finder" to set aliasList to (files of entire contents of folder (processFolderAlias as text) whose kind is not in {"CPGZ archive", "Alias"}) as alias list
tell application id archiveUtilityID to open aliasList
delay 2
tell application id archiveUtilityID to quit
end createCPGZarchives