Super User is a question and answer site for computer enthusiasts and power users. 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

How can we run a .bat file on Mac OS X?

Has anyone done it?

share|improve this question

migrated from Dec 6 '10 at 22:28

This question came from our site for professional and enthusiast programmers.

You would need to run DOS or Windows in a VM to do this e.g. using Parallels, VMware Fusion or Virtual Box. – Paul R Dec 6 '10 at 22:23
I disagree that this off topic it's about batch scripting which is programming and he's asking to run code from one language on a another machine. – Preet Sangha Dec 6 '10 at 22:25
I don't think that's off-topic - it could be that running .bat files on Mac is part of some programming task - akin to asking if there is way to do DirectX on Mac... – EFraim Dec 6 '10 at 22:27
DosBox is much lighter than Parallels/VMWare/Virtual Box. – user31752 Dec 6 '10 at 22:33
Do you need to run .bat files specifically, or do you just need to write a script on a Mac? – Sasha Chedygov Dec 6 '10 at 23:00

The equivalent to "batch files" on OS X are "shell scripts" (since OS X is derived from Unix). These are written in much the same way, as a text file with a list of commands to run. For example:


echo "This is a shell script!"
cd ~/tmp
if [ -f "foo.txt" ]; then
    echo "foo.txt exists"
share|improve this answer
bash and batch are similar, but have very distinct differences to those who are not very literate in the ways of programming. It is not that easy for everyone to translate between the two so this really doesn't answer his question at all. – MaQleod Dec 6 '10 at 22:52

It depends on how complicated your requirements are. The fact that you are even asking this questions implies that you do not have extensive knowledge of Mac so you'll probably do something simple. If you're not a unix geek there'll be a steep learning curve with shell scripts. Have a look at automator and see if it will do what you want. You can read about it on Wikipedia or type "Automator" into that help thingie you find on the mac menubar.

share|improve this answer

Mac OSX is BSD based no? You may be able to use different shell like/emulator like doscmd

share|improve this answer

For what purpose? Hard to give a good answer without more context.

.command files are similar to .bat files. Of course, the commands in whatever file you're using have to be valid for Mac (can't use a Windows .bat file with Windows command, of course).

share|improve this answer

You must log in to answer this question.