批处理:复制文件列表(TXT) [英] Batch: Copy a list (txt) of files
问题描述
我已经看到了SO一些脚本的例子,但其中没有人似乎提供了如何从.txt列表读取文件名的例子。
I've seen some scripts examples over SO, but noone of them seems to provide examples of how to read filenames from a .txt list.
这个例子是好的,但是从A所有文件到B文件夹复制
This example is good, but to copy all files from A from to B folder
xcopy c:\olddir\*.java c:\newdir /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:\\什么\\ *。*
,这些 *
需。文件列表要从一个txt文件readden。
And instead of src_folder = c:\whatever\*.*
, those *.*
need to be list of files readden from a txt file.
文件的LIST.TXT(例如)
File-list.txt (example)
file1.pds
filex.pbd
blah1.xls
可能有人建议我该怎么办呢?
Could someone suggest me how to do it?
推荐答案
鉴于你在一个名为文件-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:\target
for /f "tokens=*" %%i in (File-list.txt) DO (
xcopy /S/E/U "%src_folder%\%%i" "%dst_folder%"
)
这篇关于批处理:复制文件列表(TXT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!