1.

Solve : How to select files by date in batch?

Answer»

For ms-dos
I ve got a FOLDER with multiple identical file named by numeric way (1 to 98 for example). The file 98 is the newest, and i want to copy these ONE and only these one. The problem is, if a NEWER file is add, the file name will be 99. So i want a batch file which could copying the newest file in a folder.
Thanks for your help.Easiest way would be to sort the files descending by date and skim off the top entry:

CODE: [Select]@echo off
for /f %%i in ('dir *.* /tc /o:d /a-d /b') do (
copy %%i targetdirectory
goto tag
)
:tag

You may have to add path information to suit your environment. Replace targetdirectory to MEET your specs.

Hope this helps. 8-)perfect thanks a lot



Discussion

No Comment Found