我怎样写一个Windows批处理脚本从一个目录复制最新的文件? [英] How do I write a Windows batch script to copy the newest file from a directory?

查看:441
本文介绍了我怎样写一个Windows批处理脚本从一个目录复制最新的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要最新的文件中的一个目录复制到一个新的位置。在 FORFILES 命令到目前为止,我已经找到的资源,一个<一个href=\"http://stackoverflow.com/questions/51837/open-one-of-a-series-of-files-using-a-batch-file\">date-related问题这里,另一个<一个href=\"http://stackoverflow.com/questions/50902/how-do-i-delete-old-files-from-a-directory-while-keeping-the-most-recent-ones-o\">related问题。我只是有一点麻烦把拼在一起!我如何在该目录下复制最新的文件到一个新的地方?

I need to copy the newest file in a directory to a new location. So far I've found resources on the forfiles command, a date-related question here, and another related question. I'm just having a bit of trouble putting the pieces together! How do I copy the newest file in that directory to a new place?

推荐答案

Windows外壳,单行:

Windows shell, one liner:

FOR /F %%I IN ('DIR *.* /B /O:-D') DO COPY %%I <<NewDir>> & EXIT

这篇关于我怎样写一个Windows批处理脚本从一个目录复制最新的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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