What is the alternate for BAT file (Windows) on Mac? Does different version of OS X have different format of BAT files? I am trying to create a BAT file on Mac which normally changes directory while the file is open.
Being pretty unfamiliar with batch files, I'm not sure of the functionality available, but there are two main scripting methods on OS X which are similar:
AppleScript is a scripting language which lets you control OS X and many applications.
AppleScripts are generally easy to understand and write whilst providing a lot of advanced functionality. Here is an AppleScript which counts the files in the Applications folder:
tell application "Finder" if folder "Applications" of startup disk exists then return count files in folder "Applications" of startup disk else return 0 end if end tell
For more information about AppleScript, see:
A shell script is a script for a Unix shell.
The equivalent shell script to the above AppleScript is the following:
if [ -d "/Applications/" ]; then ls -1 "/Applications/" | wc -l fi
As you're probably going to use bash, this is a good guide to get you started:
Look up .bash or .command on mac ;)
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.