Jump to content



Photo

Batch equivalent in OS X

Answered Go to the full post os x script batch help

  • Please log in to reply
3 replies to this topic

#1 drlacus

drlacus

    The doctor

  • Tech Issues Solved: 1
  • Joined: 28-September 08
  • Location: Hungary
  • OS: Windows 8.1
  • Phone: Lumia 920

Posted 20 January 2014 - 12:48

Hi guys and girls!

 

I have a huge problem, but overcoming it could simplify my whole work. 

 

I have to perform some task and I know it could be done much more easier, but as I was educated in a Windows based environment and I do not know OS X as well as Windows or DOS. 

So, here it goes.

 

I have to create a batch file equivalent in OS X that performs the following tasks. The commands are executed in a terminal window. These perform mathematical operations with cortical brain masks and overwrite the source files as they are not needed anymore:

 

fslmaths R_S1.nii.gz -sub R_M1.niigz -bin R_S1.nii.gz 

fslmaths R_M1.nii.gz -add R_S1.nii.gz mix

fslmaths R_Premotor.nii.gz -sub mix.nii.gz -bin R_Premotor.nii.gz

fslmaths R_Premotor.nii.gz -add mix.nii.gz mix

fslmaths R_frontal_lobe.nii.gz -sub mix.nii.gz -bin R_frontal_lobe.nii.gz

fslmaths R_frontal_lobe.nii.gz -add mix.nii.gz mix

fslmaths R_temporal_lobe.nii.gz -sub mix.nii.gz -bin R_temporal_lobe.nii.gz

fslmaths R_temporal_lobe.nii.gz -add mix.nii.gz mix

fslmaths R_occipital_lobe.nii.gz -sub mix.nii.gz -bin R_occipital_lobe.nii.gz

fslmaths R_occipital_lobe.nii.gz -add mix.nii.gz mix

fslmaths R_parietal_lobe.nii.gz -sub mix.nii.gz -bin R_parietal_lobe.nii.gz

 

How to create this file and after inserting the "batch" file in a given folder can it be executed folder specifically?

 

Thank you for your help and please forgive my noobness :D



Best Answer Eric , 20 January 2014 - 13:53

You need a shell script. Just put those commands in a text file and put

#!/bin/sh
on the first line of it. After setting execute permissions as vitorio mentioned you should be able to run it as if it was a command either from a terminal or the GUI. Go to the full post



#2 +virtorio

virtorio

    4089 III

  • Tech Issues Solved: 11
  • Joined: 28-April 03
  • Location: New Zealand
  • OS: OSX 10.9, Windows 8.1
  • Phone: Samsung Galaxy SIII

Posted 20 January 2014 - 13:00

You need to give the file the 'execute' permission.

 

This page gives a basic overview of how permissions work in OSX and how to set them.

 

http://www.macinstruct.com/node/415



#3 Eric

Eric

    Neowinian Senior

  • Tech Issues Solved: 12
  • Joined: 02-August 06
  • Location: Greenville, SC

Posted 20 January 2014 - 13:53   Best Answer

You need a shell script. Just put those commands in a text file and put
#!/bin/sh
on the first line of it. After setting execute permissions as vitorio mentioned you should be able to run it as if it was a command either from a terminal or the GUI.

#4 OP drlacus

drlacus

    The doctor

  • Tech Issues Solved: 1
  • Joined: 28-September 08
  • Location: Hungary
  • OS: Windows 8.1
  • Phone: Lumia 920

Posted 20 January 2014 - 21:27

Thank you for your help guys!

 

It worked :)