中国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-08-06 20:50
48,039 topics / 350,124 posts / today 0 new / 48,252 members
DOS批处理 & 脚本技术(批处理室) » [Help] Get the name of the most recently created file
Printable Version  730 / 7
Floor1 chenjie9803 Posted 2007-12-05 16:08
新手上路 Posts 3 Credits 8
There is a folder with N files in it. The filenames follow a certain pattern, specifically like this: 00001_20071105_023015_890.txt,00002_20071105_032915_561.txt,.....,00012_20071105_233014_743.txt

Is there any way to get the filename of the one that was created most recently?
Floor2 lxmxn Posted 2007-12-06 04:04
版主 Posts 4,938 Credits 11,386
Similar questions have already been solved N times, search the forum!!!
Floor3 Climbing Posted 2007-12-06 10:20
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
Look into the sorting options of the dir command, for example sorting by time.
Floor4 tempuser Posted 2007-12-06 14:29
高级用户 Posts 261 Credits 547
Originally posted by chenjie9803 at 2007-12-5 16:08:
There is a folder with N files in it. The filenames follow a certain pattern, specifically like this: 00001_20071105_023015_890.txt,00002_20071105_032915_561.txt,.....,00012_20071105_233014_743.txt

Is there any way to get the filename of the one that was created most recently?

I'm a newbie too!
dir *.txt /o:d |find "latest date"
Floor5 chenjie9803 Posted 2007-12-07 16:45
新手上路 Posts 3 Credits 8
I did search, and there wasn't what I wanted.

Let me state the full requirement: right now there is a program that generates 1 log file every hour, with one folder per day. Now the requirement is to copy each log to the remote server as soon as it is generated.
Floor6 Climbing Posted 2007-12-07 17:02
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
If that's the case, then a command-line sync tool can completely solve the problem. For example, cmdSync. You only need to use the sync software to periodically synchronize the local log directory to the server through Scheduled Tasks. There's no need to get the latest filename, unless there are stricter or additional requirements.
Floor7 chenjie9803 Posted 2007-12-07 17:13
新手上路 Posts 3 Credits 8
Right now I'm just thinking about how to do it with a script........

Just getting the latest filename is enough
Floor8 AlexZhang Posted 2007-12-08 10:12
系统支持 Posts 435 Credits 1,011
Do you have to use a script?
I'll just tell you directly then.
A script isn't the simplest solution.
You can try a programming language...
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023