title: control copy files between two directories
body: <p>I need to copy files from one folder to another folder. In the first folder I have files...when I begin to copy from one folder to the other one, still I have not all the files...they are coming...so I need to copy the files testing if they are in the first folder...if they exist, copy to the other folder, if not, try sometimes till the file arrives. I have prepare the following code but it is not enough. I need help. </p>
  
  <pre><code>codi=( 000 003 006 009 012 015 018 021 024 027 030 033 036 039 042 045 048 051 054 057 060 )
  for c in ${codi[@]};do
  
  FILE=$dir1/gfs.t00z.pgrb2.0p50.f$c
  if [ -f "$FILE" ]; then
  echo "File $FILE exists"
  cp  $dir1/gfs.t00z.pgrb2.0p50.f$c $dir2
  else
  echo "File $FILE does not exist"
  cont=100
  until [ $cont -lt 1 ];do
  if [ -f "$FILE" ];then
  cp  $dir1/gfs.t00z.pgrb2.0p50.f$c   $dir2
  else
  echo "still File $FILE does not exist" $FILE
  fi
  let cont-=1
  echo "$cont"
  sleep 3
  done
  sleep 10
  fi
  done
  </code></pre>
  
  <p>Now this code copies the files to the other folder, when one file isn't, the programme searches again the file after some seconds...but when the file arrives...the programme doesn't detect it...something in the loop may be bad...any help please...</p>