-
-
Save dnnsmnstrr/c02ae3d5be5ab484b595cb8aea6cf65b to your computer and use it in GitHub Desktop.
Script runner - asks for input first and shows folder prompt if no name is given
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
--- | |
-- Script-Runner | |
--- | |
-- set path to script folder | |
set _Path to ("PATH_TO_YOUR_SCRIPT_FOLDER") | |
set scriptInput to text returned of (display dialog "Enter name of script to run" default answer "" buttons "OK" default button "OK") | |
if scriptInput is equal to "" then | |
-- prompt user to choose a file from script folder | |
set scriptLaunch to choose file with prompt "Choose a script to run" default location _Path as POSIX file | |
else if scriptInput contains scriptInput then | |
set scriptLaunch to _Path & "/" & scriptInput & ".scpt" | |
end if | |
try | |
-- run chosen script | |
run script scriptLaunch | |
on error | |
display alert "Your script failed to launch." | |
end try | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initial version: https://gist.github.com/unforswearing/ca87127c3b1d4abdaa47ec325b9351d3