#/bin/csh

#if (! -d $HOME/tbss.work) then
# echo "You must first run 'tbss'!"
#endif

set dirname=namd-tutorial-files
set namdpath=/Users/tcblaptop/Desktop/sumschool03/tutorials/02-namd-tutorial/namd-tutorial-files
set mypath=$HOME/$dirname

if (! -d $HOME/$dirname) then

mkdir $mypath
cd $mypath

echo "Creating directory namd-tutorial-files... "

foreach l (`ls $namdpath`)
  #echo $PWD
  mkdir $mypath/$l
  if ( $l != 2-7-echoes ) then  
  	if ( $l == 3-1-pullcv ) then 
  	  mkdir $mypath/$l/analysis
  	endif
  	cd $mypath/$l
  	foreach a (`ls $namdpath/$l`)
    		if (-d $namdpath/$l/$a ) then
    		    ln -s $namdpath/$l/$a .
    		else
    		    cp $namdpath/$l/$a .
    		endif 
  	end
  else
  	cd $mypath/$l
   	foreach a (`ls $namdpath/$l`)		
		if (-d $namdpath/$l/$a ) then
			mkdir $mypath/$l/$a
			cd $mypath/$l/$a
	#		#echo $PWD
			foreach b (`ls $namdpath/$l/$a`)
				if (-d $namdpath/$l/$a/$b ) then
    		    			ln -s $namdpath/$l/$a/$b .
    				else
    				    cp $namdpath/$l/$a/$b .
    				endif	 
			end
			#echo $PWD
		else
		 	cp $namdpath/$l/$a .
		endif	
	end
  endif 
end


echo "Created the tutorial directory. Enter it by typing: "
 echo "        cd ~/namd-tutorial-files"
 echo "Please start the tutorial."
else
 echo "Tutorial directory already exists. Enter it by typing:"
 echo "        cd ~/namd-tutorial-files"
endif
