[英]Multiple files to one folder in batch
I am looking to do a simple Batch process to copy log files in 3 different sub directories of the same directory to another folder elsewhere. 我正在寻找一个简单的批处理过程,以将同一目录的3个不同子目录中的日志文件复制到其他位置的另一个文件夹中。
my code is at the moment: 目前,我的代码是:
for /r c:\users\...\Unzipped %%g in (*.log) do move /-y "c:\users\...\Unzipped\" "c:\users\...\Log_Files"
I continue to receive 10 responses saying my code syntax is in correct, meaning by my understanding at least the first part is somewhat correct. 我继续收到10条回答,说我的代码语法正确,这意味着,根据我的理解,至少第一部分是正确的。
The issue is with the origin part of the move command. 问题出在移动命令的原点。 how is it possible to say in essence, "from 3 different sub folders"?
从本质上说“来自3个不同的子文件夹”怎么可能?
Your original command 您的原始命令
for /r "c:\root\folder" %%g in (*.log) do move /-y "%%~fg" "c:\target\folder"
That is, for each log file, recursively under the indicated starting folder, move the file ( %%~fg
is the full path to the file being referenced by %%g
) to the target folder 也就是说,对于每个日志文件,在指定的起始文件夹下递归地将文件(
%%~fg
是%%g
所引用文件的完整路径)移动到目标文件夹
If you want to directly indicate the three source folders from where the files must be taken, then 如果要直接指示必须从中获取文件的三个源文件夹,则
for %%g in ("c:\root\f1\*.log" "c:\root\f2\*.log" "d:\somewhere\*.log"
) do move /-y "%%~fg" "c:\target\folder"
But in this case, you can not include the /r
switch in the for
command for a recursive search. 但是在这种情况下,您不能在
for
命令中包含/r
开关以进行递归搜索。
这将扫描所有子文件夹并搜索* .log
for /f %%f in ('dir /s/b c:\users...\Unzipped\*.log') do move /-y %%f "c:\users...\Unzipped\Logfiles"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.