Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Look here or here – Mathias711 Jun 15 '14 at 12:04
Look at Unix shell scripts or python, perl or other scripting languages – Mark Jun 15 '14 at 12:26
Let's focus on general ways to do things similar to BAT files in this question. If you need help in getting a specific problem solved please ask a new question. – patrix Jun 15 '14 at 15:13

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

    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
            return 0
        end if
    end tell

    For more information about AppleScript, see:

  • Shell script

    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

    As you're probably going to use bash, this is a good guide to get you started:

share|improve this answer

Look up .bash or .command on mac ;)

share|improve this answer

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.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.