#run this script from the Freesurfer Subjects Directory...alterntively, you can modify the script to work automatically 
#from the the FreeSurfer Subjects Directory Variable. However, since you might not be using the bash shell, maybe that variable wont be available. Anyway..
filename=/home/local/AD3/jlee31/Desktop/NORA/segmentz     #This points to a file you will make in which every line contains a subject directory name. 
	
#The script will read this file line by line to get the data from each subject listed in the script
statsfile=rh.curv.stats #Tells the scipt which kind of stat files you want to collect

#Name the file you want to put your results into
resultsFileName=results.txt

#Ok here we go
while read line; do

    	sub=`echo $line | cut -d\. -f1`  #gets the subject name from the file in the first line of this script

	currentStatsFile=./"$sub"/stats/$statsfile #puts together the fullpath of the stats file
	
	#Next Grep finds a line in the file (stored in the variable $myStatsFile) that mathces the criteria 
	#(for example here I find the line "Raw Total Surface Area:" and echos that out to a result text file
	echo $sub"	"`grep "Raw Total Surface Area:" $currentStatsFile` #>> $resultsFileName  #creates a results txt file
         
	
done < "$filename"
