#!/bin/csh

foreach d (??????)
  set n = `ls -1 $d/*.dat | wc -l`
  if( $n != 0 ) then
  foreach f ($d/*.dat)
    set base = `basename $f`
    set yymmdd = `echo $base | cut -c 9-14`
    set year = `echo $base | cut -c 7-10`
    if( ! -d  ../spectrum_data/${year}/${yymmdd} ) then
       mkdir  ../spectrum_data/${year}/${yymmdd}
    endif
    if( ! -e  ../spectrum_data/${year}/${yymmdd}/$base ) then
       echo "mv $f  ../spectrum_data/${year}/${yymmdd}/ "
       mv $f  ../spectrum_data/${year}/${yymmdd}/
    endif
  end
  endif
end

