从多个目录复制文件名列表 [英] Copy list of file names from multiple directories

查看:118
本文介绍了从多个目录复制文件名列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的论坛.我需要一些建议.我需要代码帮助,以获取带有文件名列表的文本文件并将文件从多个文件夹复制到一个文件夹中,但是必须以文件的最新修改日期结束.有数百个包含成千上万个文件的文件夹.

i'm new to the forum. I need some advice. I need help with a code to take a text file with a list of file names and copy the files from multiple folders in to one folder, but it has to end up with the most recent modified date of the file. There are hundreds of folders containing the thousands of files.

我下面有一个批处理代码来复制文件,但是它并不总是以最新文件结尾. 如果有某种方法可以使下面的代码按数字顺序搜索文件夹,那么该方法可以代替以随机顺序搜索文件夹.我不在乎最终使用的代码是否为批处理, vbs或其他任何内容.

I have a batch code below to copy the files, but it does not always end up with the newest file. If there is some way to make the code below search the folders in numerical order, that would work instead of it searching in a random order. I do not care if the code i end up using is batch, vbs, or whatever.

mkdir %userprofile%\desktop\print
set FIILELIST=%userprofile%\desktop\print.txt
set FILESPATH="\\server\folder"
set DESTPATH=%userprofile%\desktop\print

for /f %%X in (%FIILELIST%) do call :COPY_FILES "%%X"
goto :eof

:COPY_FILES
for /r %FILESPATH% %%I in (%~1) do copy "%%I" "%DESTPATH%"

推荐答案

for /r %FILESPATH% %%I in (%~1) do Xcopy /D "%%I" "%DESTPATH%"

XCOPY /D仅在目标文件不存在或目标文件早于源文件时复制.

XCOPY /D will only copy if the destination file does not exist or if the destination file is older than the source.

这篇关于从多个目录复制文件名列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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