将 txt 文件中列出的文件复制到另一个目录中

Copy files listed in a txt file and put it in another directory

我正在尝试使用文本文件复制 multiples/hundreds 个文件并将其放在另一个目录中 例如我的源目录有这个文件。

09_yehey_123456.SENT
09_yohoo_987654.SENT
09_testy_789065.SENT
09_lolol_124125.SENT
09_hahah_241567.SENT

文本文件看起来像这样(这个文本文件包含我应该只从源目录复制的文件)

09_yehey
09_yohoo
09_testy

这是我尝试使用的代码

for /f "delims=" %%i in (files2.txt) do echo F|xcopy "C:\Users\username\source\%%i*" "C:\Users\username\Documents\dest\%%i"
PAUSE

源目录中的 * 似乎不能用作通配符

像这样尝试:

  for /f "delims=" %%i in (files2.txt) do (
     copy /y "C:\Users\username\source\%%~ni*" "C:\Users\username\Documents\dest\"
    )
    PAUSE

由于文本文件中的名称与实际文件中的名称不同,您需要通配符。