Recommended Posts

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

Link to comment
https://www.neowin.net/forum/topic/1197325-batch-equivalent-in-os-x/
Share on other sites

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

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.
  • Like 1
This topic is now closed to further replies.