Copy a list (txt) of files

后端 未结 5 1050
逝去的感伤
逝去的感伤 2020-11-29 22:27

I\'ve seen some scripts examples over SO, but none of them seems to provide examples of how to read filenames from a .txt list.

This example is good, so as to copy a

5条回答
  •  攒了一身酷
    2020-11-29 23:21

    I just tried to use Frank Bollack and sparrowt's answer, but without success because it included a /U switch for xcopy. It's my understanding that /U means that the files will only be copied if they already exist in the destination which wasn't the case for me and doesn't appear to be the case for the original questioner. It may have meant to have been a /V for verify, which would make more sense.

    Removing the /U switch fixed the problem.

    @echo off
    set src_folder=c:\whatever
    set dst_folder=c:\target
    for /f "tokens=*" %%i in (File-list.txt) DO (
    xcopy /S/E "%src_folder%\%%i" "%dst_folder%"
    )
    

提交回复
热议问题