1

I have a directory where so many files created daily and need to copy the new files which were generated. And all files will be created with starting name abc_ Ex:I have a file abc_0520123.pdf on the next day two files were created abc_0521234.pdf and abc_0521254.pdf now I want to copy only these two files created newly. Please help me how can I compare old files with new one and to copy them.

closed as unclear what you're asking by slm, derobert, Ramesh, Bernhard, Braiam May 30 '14 at 18:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    It is unclear to me. Is there any logic in the filenames? Or you want to copy every file created in the past 24h? – Bernhard May 30 '14 at 17:34
  • I need to copy the files which are created newly. If the file already has been copied it should not be copied. – Aravind Jun 4 '14 at 11:50
2

With GNU find:

find . -type f -newermt "today 00:00" -exec echo {} +

If you want to handle only those files whose name begins with abc_ then:

find . -type f -name 'abc_*' -newermt "today 00:00" -exec echo {} +

Of course, you would finally do something different from echo, e.g.

find . -type f -newermt "today 00:00" -exec mv --target-directory=/move/here {} +
  • when i use this command i am getting error like "find: 0652-017 -newrmt is not a valid option" – Aravind May 30 '14 at 15:50
  • 1
    @user2910201 Obviously you have not always used copy and paste as it is -newermt in my code but -newrmt in your comment... – Hauke Laging May 30 '14 at 16:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.