Skip to content

Instantly share code, notes, and snippets.

@themorgantown
Created March 8, 2018 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themorgantown/dc601191479f9ae7bd9f87570175dc0a to your computer and use it in GitHub Desktop.
Save themorgantown/dc601191479f9ae7bd9f87570175dc0a to your computer and use it in GitHub Desktop.
Folder Action for running SVG files through SVGO ( https://github.com/svg/svgo )
# To use this as a Folder Action, first place it within your
# Folder Actions Folder.
# In Terminal, insert this:
# open ~/Library/Scripts/Folder\ Action\ Scripts
# You may need to create that folder, by first running
# open ~/Library/Scripts/
# Then creating the Folder Action Scripts folder.
# This script requires SVGO, which can be installed with Homebrew:
# brew install svgo
on adding folder items to this_folder after receiving these_items
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
set the file_path to the POSIX path of this_item
try
do shell script "/bin/bash -l -c 'svgo \"" & file_path & "\"'"
on error errStr number errorNumber
display dialog "Error: " & errStr buttons {"OK"} with icon stop
return number
end try
end repeat
end adding folder items to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment