[英]Move .txt files in different folders to a single folder using Batch file
I'm trying to move all .txt files in different folders to a single folder using a batch file, I'm new to batch coding so I'm having some difficulties. 我正在尝试使用批处理文件将不同文件夹中的所有.txt文件移动到单个文件夹,我是批处理编码的新手,因此遇到了一些困难。
My code is as follows: 我的代码如下:
FOR /D /r %%G IN ("C:\Users\Rodrigo\Desktop\PR\2016\08.2016\") DO MOVE G\*.txt C:\Users\Rodrigo\Desktop\PR\2016\
See the correct syntax of For /r or in an open cmd window type help for
请参阅For / r的正确语法或在打开的cmd窗口中键入
help for
@Echo off
For /r "C:\Users\Rodrigo\Desktop\PR\2016\08.2016\" %%G IN (*.txt
) Do echo Move "%%G" "C:\Users\Rodrigo\Desktop\PR\2016\"
Pause
If the output to screen looks OK remove the echo in front of the move command. 如果屏幕输出看起来正常,请除去移动命令前面的回声。
You could do this all in PowerShell. 您可以在PowerShell中完成所有这些操作。 I am not sure it will work if you do not pass the $_.FullName which contains the path to the file.
如果您不传递包含文件路径的$ _。FullName,我不确定它是否会起作用。
Get-ChildItem -Path "C:\Users\Rodrigo\Desktop\PR\2016\08.2016\" -Filter *.txt | `
ForEach-Object { $_.FullName } | `
Move-Item -Destination "C:\Users\Rodrigo\Desktop\PR\2016\"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.