How to create a simple "batch file"

Discussion in 'Mac Programming' started by BigladUK, Jan 3, 2009.

  1. BigladUK macrumors member

    Mar 29, 2004
    Sorry to bother you guys but I'm trying to work out how to do 4 simple tasks that I currently manually do.

    If I was doing this under windows I could simply write a batch file with the commands in but I'm unsure of how to go about the same thing on my Mac.

    The simple command are

    Mount 2 Network shares
    Change folders to /applications/Moviejukebox
    Run with some switches.
    Unmount the 2 network shares.

    I looked at automator but couldn't really get my head round it and I'm no developer.

    Should I add the commands I want in to the .sh file ?

    I was thinking maybe applescript is the way to go but have no idea of the commands.

    Like I said if I was doing this under windows then simple dos commands could be used and I would put these in a batch file.

    Any one help me out or point in the right direction ?

    Thanks in advance and please be gentle with me


  2. 2xMcK macrumors newbie

    Dec 25, 2008
    That should be easy to do with applescript.

    Open Script editor and type something like:

    do shell script "command1"
    do shell script "command2"

    Then click execute to try it, and if it works as expected, choose "Save as Application", and there you go.
  3. BigladUK thread starter macrumors member

    Mar 29, 2004
    Thanks for the reply but I'm not sure I have enough skills to be able to do what I need from he commands you have shown above.

    I've opened up applescript and can see it's a very powerful application and can also see if has lots of Finder script commands so I'm sure I'll be able to work our how to mount and unmount my shares but how do I pass a CD command and then a command line in to the terminal window ?

    My scripting skills as basic and I have no Mac scripting skills at all.

    Any more help would be appreciated


  4. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    There is nothing stopping you from using Unix shell scripts if you prefer.
  5. Ramashalanka macrumors regular

    Dec 26, 2008
    Lanka Ravi Shanka
    If you want unix shell code, you could type something like this. You can type it in TextEdit, save it without an extension, and run it (eg by double clicking it in Finder or dragging it from Finder onto your desktop).

    First you should get the details of your mount working (the directory name etc) by typing it directly into terminal.

    mkdir /Volumes/tmp1
    mkdir /Volumes/tmp2
    sudo mount_afp afp://uname:pwd@computername/dir1 /Volumes/tmp1
    sudo mount_afp afp://uname:pwd@computername/dir2 /Volumes/tmp2
    cd /applications/Moviejukebox
    ./ -options here
    umount /Volumes/tmp1
    umount /Volumes/tmp2

Share This Page