File Copy based on file receive date

I have bunch of files in my source folder like below and every day based on date I am receiving file ex: Nov 28,Nov 29,Nov 30 ...

-rw-rw-r--+ 1 root  root 20 Nov 27 06:00 aaaa27.txt
-rw-rw-r--+ 1 root  root 20 Nov 28 06:00 aaaa28.txt
-rw-rw-r--+ 1 root  root 20 Nov 29 06:00 aaaa29.txt
  1. I want to copy all files into another destination folder.
  2. Copy should happen based on date like Nov 28,Nov 29..and so on.
  3. Script will not copy the old file dated.
  4. Script will copy only the new file which i receive everyday.

Thanks in advance

Yes?
And where are you having an issue?
What have you done so far?

Already i am trying to achieve this by below script

# Go to the directory from where want to copy files

cd /mydir
find . -type f -mtime 1 -exec cp {} /destdir\;
find . -type f -mtime 1 -exec cp {} /destdir1\;

And then installing this script in crontab as @daily so it can be run everyday 12 am.

Is there any other way to achieve?

The find -mtime 1 primary looks for files that are exactly 24 hours old. If you run two invocations of find a second apart, they will not copy the same file (if either of them finds any file at all).

If your script runs close to midnight every night and your daily file comes in around 6am every morning, you can get by with:

cd /mydir
find . -type f -mtime -1 -exec cp {} /destdir\;
find . -type f -mtime -1 -exec cp {} /destdir1\;

to copy files that are less than 24 hours old.

If you might get a file close to midnight (just before, while, or just after your script is run) or your cron job might not run every day (and you still want to copy each file exactly once), you could try something like:

cd /mydir
touch /destdir/.now
find . -type f -newer /destdir/.previous -exec cp {} /destdir \;
find . -type f -newer /destdir/.previous -exec cp {} /destdir1 \;
mv /destdir/.now /destdir/.previous

You'll need to create /destdir/.previous with an appropriate timestamp before you run this script the first time, but after that it should do what you want. There is, however, a chance that a file will be copied twice (once today and once again tomorrow) if a file is created in /mydir while your script is running.

Thanks Don Cragun for your reply..

Surly I will do that and monitor. Any issue i face let you know...