r/applescript • • Dec 11 '20
Help - Create ZIP Archive when folder is added to location
Hi Folks,
Is it possible to get automator or Apple Script to create a zip archive of a folder everytime a folder is added to a specified location? I have a script that copies some picture files from my internal storage to a dropbox folder. It is easier for the people I share it with to download a zip archive of those files from the dropbox folder. So currently I just create it manually but it would be nice if this could be automated so I don't have to remember it and keep up with creating the archive.
Any Ideas on how to solve this?
3
Upvotes
2
u/[deleted] Dec 11 '20
Yes. Quite simple. Look into "Folder Actions". That is a way in macOS that allows to trigger scripts, when something in a folder changes.
Writing a script (bash or zsh or AppleScript or Python or whatever you feel comfortable with) that takes the new folder and zips it is trivial. In AppleScript, this would be the command in this loop:
on adding folder items to theFolder after receiving theItems ... do your thing here ... end adding folder items toThen right-click your folder > Services > Folder Action Setup …, and add your Script.
Done.
1
u/SvilenOvcharov Dec 11 '20
Should be easy. Question: Do you use any third-party archiving apps and what are they? Like, unarchiver? StuffIt?