简体   繁体   English

Windows 7 Batch - 创建子文件夹,然后查找文件名中包含特定文本的文件并将这些文件移动到新创建的子文件夹中

[英]Windows 7 Batch - Create subfolder, then find files with certain text in file name and move those files in the newly created subfolder

Tried my best searching for a solution but close to my need was this example which did not work.尽我最大的努力寻找解决方案,但接近我的需要的是这个没有工作的例子。 Bash: Moving multiple files into subfolders Bash:将多个文件移动到子文件夹中

I am not a programmer so unable to create the batch file myself for Windows 7. Any help will be appreciated.我不是程序员,因此无法自己为 Windows 7 创建批处理文件。任何帮助将不胜感激。


Needed code for a batch file that does the following:-执行以下操作的批处理文件所需的代码:-

  1. Searches the folder for all files that have "_F1" in the file name在文件夹中搜索文件名中包含“_F1”的所有文件
  2. Creates a subfolder named as "F1" where this file is located在此文件所在的位置创建一个名为“F1”的子文件夹
  3. Move all the files searched in step 1 to the folder "F1" created in step 2将步骤 1 中搜索到的所有文件移动到步骤 2 中创建的文件夹“F1”

Ideally, the batch file should execute from parent folder and should complete the 3 steps in all subfolders at least till 3 levels down the parent folder.理想情况下,批处理文件应从父文件夹执行,并应在所有子文件夹中完成 3 个步骤,至少到父文件夹下 3 个级别。


Thanks in Advance for any help.在此先感谢您的帮助。


I tried and came up with this.我尝试并想出了这个。 Works, but is very raw.有效,但非常原始。 Needs to be run manually from inside of each folder (100's of them)需要从每个文件夹内部手动运行(其中 100 个)

MKDIR F1 

MKDIR F2 

DO 500

move *_F1*.* F1

move *_F2*.* F2

ENDDO

Try like this :像这样尝试:

@echo off
for /f "delims=" %%a in ('dir /s/b/a-d *.* ^| find /i "_F1"') do (
if not exist "%%~dpaF1" md "%%~dpaF1"
move "%%~fa" "%%~dpaF1")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 批处理文件以在文件夹中创建新的子文件夹,将文件移动到目录中所有文件夹的新创建的子文件夹 - batch file to create new subfolder in folder, move file to newly created subfolder, for all folders in directory 创建批处理文件以删除,重命名和移动多个文件的多个子文件夹 - Create batch file to delete,rename and move multiple files multiple subfolder Windows批处理脚本在包含子文件夹后命名文件并复制到根目录 - Windows batch script to name files after containing subfolder and copy to root 用相同的名称创建新的子文件夹并将文件移动到新文件夹 - Create new subfolder with same name and move files to the new folder 批处理文件以计算文件夹中的所有文件和子文件夹文件,并使用批处理文件以文件夹名称写入输出文件 - batch file to count all files in a folder and subfolder files and write output file in folder name using batch file 将文件移动到目标目录的子文件夹中 - Move files into a subfolder of a destination directory 如何将特定文件夹的每个子文件夹中的所有 *.pdf 文件移动到每月创建的子文件夹? - How to move all *.pdf files in each subfolder of a specific folder to a monthly created subfolder? 从当前文件夹中的所有文件以及子文件夹Windows批处理中的文件中删除前缀 - Remove Prefix from all file in current folder as well as files in subfolder windows batch 在子文件夹而不是当前文件夹中批处理文件 - batch process files in subfolder instead of current folder Windows 批处理 - 在具有特定名称的文件夹中查找图像文件 - Windows Batch - Find image files inside folders that have a certain name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM