Copy list of file names from multiple directories

主宰稳场 提交于 2019-12-08 09:03:43

问题


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.

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%"

回答1:


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

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



来源:https://stackoverflow.com/questions/21148607/copy-list-of-file-names-from-multiple-directories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!