Skip to content

Instantly share code, notes, and snippets.

@walm
Created November 18, 2012 12:33
Show Gist options
  • Save walm/4105005 to your computer and use it in GitHub Desktop.
Save walm/4105005 to your computer and use it in GitHub Desktop.
Run Slicy on PSD from command line using AppleScript
on run argv
set input_file to POSIX file (item 1 of argv)
set output_path to item 2 of argv
-- TODO: add some error handling :)
-- make sure output folder exists
do shell script "mkdir -p " & output_path
-- drop input file on Slicy app
tell application "Finder"
activate
open input_file using application file "Slicy.app" of folder "Applications" of startup disk
end tell
-- Save slices to output folder
tell application "System Events"
tell application process "Slicy"
delay 5 -- might need to set this higher depending on PSD layers
keystroke "s" using {command down} -- do save
delay 1
keystroke "g" using {shift down, command down} -- set output path with go to folder
keystroke output_path
keystroke return
delay 1
keystroke return
delay 2
keystroke "q" using {command down} -- quit
end tell
end tell
end run
#!/bin/sh
osascript ~/bin/sliceit.scpt "$PWD/$1" "$PWD/$2"
@walm
Copy link
Author

walm commented Nov 18, 2012

Put files in ~/bin (if that is in your path)
chmod +x sliceit.sh

Then run it like

sliceit.sh path_to/input.psd path_to_output/folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment