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

Has anyone done it?

  • 2
    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
  • 3
    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"
  • 5
    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.


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


If you must, an effective (but heavyweight) way to run a .bat file on various Unix flavours, including OSX, is with Wine (The WINdows Emulator) : https://www.winehq.org/

Then you can run .bat scripts via: $ wine cmd /c MyScript.bat

Further information here: http://www.linux.org/threads/running-windows-batch-files-on-linux.7610/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy