简体   繁体   English

多个文件批量保存到一个文件夹

[英]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.

相关问题 通过批处理将许多不带扩展名的文件复制到一个主文件夹中 - Copying many files without extension into one main folder via batch 将文件从一个FTP文件夹移动到同一FTP的另一个文件夹的批处理文件? - Batch file to move files from one FTP folder to another folder in the same FTP? 如何从一个文件夹中读取多个txt文件 - How to read multiple txt files from one folder 在 R 的一个文件夹中的多个.txt 文件上运行循环 - Running a loop on multiple .txt files in one folder in R 将多个目录中相同类型的所有文件移到一个文件夹中 - Move all files of same type in multiple directories up one folder 在从一个文件夹传输到另一个文件夹的过程中修改多个文件 Python - Modifying multiple files during a transportation from one folder to another Python 如何在WordPress的一个文件夹中合并多个插件文件? - How to combine multiple plugin files in one folder in WordPress? Python:将文件从不同位置的多个文件夹移动到一个文件夹中 - Python: Move files from multiple folders in different locations into one folder 批处理文件比较两个文件夹返回不在一个文件夹中的文件 - Batch file compare two folders return files that aren't in one folder 使用批处理文件删除文件夹中的pdf文件 - Delete pdf files in a folder using a batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM