I have a shell script that checks if folders have a set number of files and displays error messages to the user. I use applescript to display the error message. Is there a way to pass the variables of the shell script to the AppleScript?
Here is what I have:
declare -i count=5;
osascript -e 'tell app "Xcode" to display dialog "Counted $count items." buttons {"Continue"}'
I want the output to be Counted 5 items. but it just comes out as Counted $count items. How can I pass a shell script variable to the applescript?
There are three solutions:
Use “” instead of ” so that the $var will be expanded by the shell
Close the quote, put the var, and reopen with no spaces (e.g. ‘string’$var’rest of string’). However, this is unsafe if the variable can contain spaces.
Use formal command line arguments with your AppleScript script