复制文件列表 (txt) [英] Copy a list (txt) of files

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

问题描述

我在 SO 上看过一些脚本示例,但似乎没有一个提供如何从 .t​​xt 列表中读取文件名的示例.

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.

这个例子很好,把A文件夹中的所有文件复制到B文件夹

This example is good, so as to copy all files from A to B folder

xcopy c:olddir*.java c:
ewdir /D /E /Q /Y

但我需要像下一个这样的东西,我可以在其中填充源文件夹和目标文件夹:

But I need something like the next, where I can fill actually the source and destination folder:

 @echo off
 set src_folder = c:whatever*.*
 set dst_folder = c:foo
 xcopy /S/E/U %src_folder% %dst_folder%

而不是 src_folder = c:whatever*.*,那些 *.* 需要是从 txt 文件中读取的文件列表.

And instead of src_folder = c:whatever*.*, those *.* need to be list of files read from a txt file.

文件列表.txt(示例)

File-list.txt (example)

file1.pds
filex.pbd
blah1.xls

有人可以建议我怎么做吗?

Could someone suggest me how to do it?

推荐答案

给定名为 File-list.txt 的文件中的文件名列表,以下几行应该满足您的要求:

Given your list of file names in a file called File-list.txt, the following lines should do what you want:

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

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

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