开发者

Get the latest file from a list of files by name and merge it with another file in a Windows batch file?

I have a list of files in a folder. They are named like this: 2011-04-14_00-00-24

Example list:

2011-04-14_00-00-24

2011-04-13_00-01-12

2011-07-08_00-00-28

2010-03-12_00-00-45

...

Now I want to get the latest file according to the filename from that list, in this case its 2011-04-14_00-00-24. The file I get should be merged with another file. How would I get the latest file and do the merge for the 2 files?

开发者_Python百科Thanks :-)


You can get the latest file with this:

for /f "delims=" %%x in ('dir /o-n /b') do (set "Latest=%%x" & goto le)
:le

I'm not quite sure what you mean with merging; if that is concatenating two files:

copy somefile+"%Latest%" newfile
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜