Created
March 8, 2018 16:54
-
-
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 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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