China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 11:03
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » I only want to copy the latest file View 5,360 Replies 0
Original Poster Posted 2019-12-19 13:19 ·  中国 北京 联通
新手上路
Credits 4
Posts 1
Joined 2019-12-18 09:10
6-year member
UID 183740
Gender Male
Status Offline
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?
Forum Jump: