中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-23 12:56
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » I only want to copy the latest file
Printable Version  5,508 / 0
Floor1 handsome1234 Posted 2019-12-19 13:19
新手上路 Posts 1 Credits 4
I just want to copy files from the past 1 or 2 days or the latest files (and the number of files in the two directories is inconsistent), and not copy others.
I want to copy 2 files in the current folder that meet the conditions and copy them to another place.
The current folder is db, the location where daily backups are stored. I want to copy the latest backup of each day to another place
for /f "tokens=FY_*.bak" %%i in ('dir F:\DB_BAK /o:-d-s /b') do (set file=%%~fi)&(goto :next1)
:next1
copy %file% C:\ /y

I wonder what good ideas all the experts have?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023