title: How to copy files from dir and append date to filename?
body: <p>I'm trying to copy files from one directory to another and append current date to this filename. The script look like this</p>
  
  <pre><code>#!/bin/bash
  
  echo 'Move to homedir'
  cd $HOME
  
  echo 'Copy .txt files'
  NOW=$(date +"%d%m%Y")
  
  for FILENAME in *.txt
  do
          cp "${FILENAME}" "/newdir/${FILENAME}${NOW}"
  done
  </code></pre>
  
  <p>This generates an error because date is appended after file extension, like this</p>
  
  <blockquote>
    <p>file1.txt10082013</p>
  </blockquote>
  
  <p>How to avoid that?</p>