Running .bat files on a Mac

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

Has anyone done it?

5

4 Answers

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:

#!/bin/sh
echo "This is a shell script!"
cd ~/tmp
if [ -f "foo.txt" ]; then echo "foo.txt exists"
fi
1

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.

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) :

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

Further information here:

1

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like