如何在Windows中使用批处理脚本,以获得最新的文件 [英] How to get the most recent file using a batch script in windows

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

问题描述

我的zip文件日期和时间追加像 yyyymmdd_hhmmss_Demos.zip 列表。现在,如何让源文件目录最近添加的zip文件。我需要使用这个文件复制到目标复制命令。

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

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

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