简体   繁体   English

使用批处理文件将不同文件夹中的.txt文件移动到单个文件夹

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

相关问题 批处理文件可将一个文件夹中的文件和文件夹移动到另一个文件夹 - Batch file to move files and folders in a folder to another folder 批量创建基于部分文件名的文件夹并将文件移动到该文件夹​​中 - Batch create folders based on part of file name and move files into that folder 批处理文件到不同文件夹的符号链接文件到公共文件夹 - batch file to symbolic link files from different folders into common folder 如何使用批处理文件在文件夹之间随机移动文件? - How to move files randomly between folders using batch file? 使用批处理文件将嵌套的文件夹和文件移动到新位置 - Move nested folders and files to new location using a batch file 批处理文件-使用列表从文件夹中移动文件 - Batch File - Using List, move files from folders 创建批处理文件以在特定文件夹中搜索特定字符串的 .txt 文件,并将所有文件移动到新文件夹 - Creating Batch File to search .txt files in a specific folder for a specific string, and move all files to a new folder 批处理文件.txt移到另一个文件夹 - batch file move .txt to another folder 无法使用批处理文件将文件移动到文件夹中 - Unable to move files into folders using batch files 批处理脚本循环遍历文件夹,压缩文件夹中的每个文件并将其移动到不同位置的相应文件夹 - batch script loop through folders, zip each file in the folder and move it to a corresponding folder in a different location
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM