如何使用批处理文件获取最新文件? [英] How to get the most recent file using a batch file?

查看:85
本文介绍了如何使用批处理文件获取最新文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个附加了日期和时间的zip文件列表,例如yyyymmdd_hhmmss_Demos.zip.现在,如何在源目录中获取最新添加的zip文件.我需要使用copy命令将此文件复制到目标中.

I have a list of zip files with date and time appended like yyyymmdd_hhmmss_Demos.zip. Now how to get the most recently added zip file in the source dir. I need to copy this file in the target using copy command.

我找到了有关forfiles的一些信息,但是几秒钟内却不知道如何完成它.

I found some info about forfiles, but do not have an idea on how to get it done for seconds.

推荐答案

您可以使用

pushd D:\a
for /f "tokens=*" %%a in ('dir /b /od') do set newest=%%a
copy "%newest%" D:\b
popd

这篇关于如何使用批处理文件获取最新文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆