简体   繁体   English

将包含许多文件的文件夹拆分到多个子文件夹(Windows 10)

[英]Break a folder with many files to multiple subfolders (Windows 10)

I have a folder with 110.000 files and I want a way to break this folder into multiple subfolders containing say 3000 files each (with a batch script perhaps?). 我有一个包含110.000个文件的文件夹,并且我想要一种将该文件夹分成多个子文件夹的方式,每个子文件夹包含3000个文件(也许有批处理脚本?)。 (Trying a copy/paste with WinExplorer gets stuck in "Preparing to Copy".) (使用WinExplorer尝试复制/粘贴会陷入“准备复制”中。)

For example: 例如:

BigFolder
  |
NewFolder
|     |    |    |    |
Sub1  Sub2 Sub3 Sub4 Sub5...

I am surprised to find the same case of mine. 我很惊讶地发现我的同样情况。 I had 30,000 files that needed to be sorted, so I asked question on this page: Fast methods to copy(move) files in batch file 我有30,000个需要排序的文件,所以我在此页面上问了一个问题: 在批处理文件中复制(移动)文件的快速方法

This is Compo 's script: 这是Compo的脚本:

 @Echo Off If /I Not "%__CD__%"=="%~dp0" PushD "%~dp0" 2>Nul||Exit/B SetLocal EnableDelayedExpansion Set "DirN=-1" :Check_DirN Set/A "DirN+=1" If Exist "%DirN%" GoTo Check_DirN Set "limit=700" For %%A In (*.bat *.cmd *.txt) Do ( If Not Exist "%DirN%" MD "%DirN%" If /I Not "%%~nxA"=="%~nx0" RoboCopy . "%DirN%" "%%A" /MOV 1>NUL Set/A "limit-=1" If !limit! Lss 0 GoTo Check_DirN ) Echo(Task Done! Timeout -1 1>Nul 

And this is what I use and I edited for a bit for the purpose: 这就是我使用的目的,为此我做了一些编辑:

@Echo Off
If /I Not "%__CD__%"=="%~dp0" PushD "%~dp0" 2>Nul||Exit/B
taskkill /f /im explorer.exe >nul
taskkill /f /im SearchIndexer.exe >nul
sc stop WSearch >nul
sc config WSearch start= disabled >nul

SetLocal EnableDelayedExpansion
Set "DirN=-1"

:Check_DirN
Set/A "DirN+=1"
If Exist "%DirN%" GoTo Check_DirN
cls
echo Moving files to Directory %DirN%...
Set "limit=2999"
MD "%DirN%"
For %%A In (*.html) Do (
    RoboCopy . "%DirN%" "%%A" /MOV 1>NUL
    Set/A "limit-=1"
    If !limit! Lss 0 GoTo Check_DirN
)
Echo(Task Done!

start explorer.exe
start SearchIndexer.exe
sc config WSearch start= delayed-auto >nul
sc start WSearch >nul
Timeout -1 1>Nul

You can remove taskkill , start and sc part if desired. 您可以根据需要删除taskkillstartsc part。 I added this part because explorer and Windows Search Indexer will cause waste of memory when moving files. 我添加此部分是因为资源管理器和Windows搜索索引器将在移动文件时浪费内存。 I recommend you to run the script with Administrator privilege. 我建议您以管理员权限运行脚本。

Try to test the script in small scale to see if it does work. 尝试以小规模测试脚本以查看其是否有效。

暂无
暂无

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

相关问题 Windows批处理以覆盖文件夹和子文件夹中的现有文件 - Windows Batch to Overwrite Existing files in folder and subfolders 使用Windows cmd读取文件夹的子文件夹和这些子文件夹中的文件 - Read a Folder's subfolders and files in these subfolders using Windows cmd 使用 Windows 批处理脚本将多个文件从子文件夹移动到单个文件夹 - Move Multiple Files from Subfolders to Single Folder using Windows batch script 如何将特定文件从多个子文件夹移动到各自的父文件夹? (Windows批处理) - How can I move specific files from multiple subfolders to their respective parent folder? (Windows batch) Windows批处理将文件从子文件夹复制到一个文件夹 - Windows batch copy files from subfolders to one folder Windows批处理文件,用于将文件从特定的子文件夹移动到另一个文件夹 - Windows batch file to move files from specific subfolders to another folder 将所有文件从多个子文件夹移至父文件夹 - Move all files from multiple subfolders into the parent folder 将文本文件中具有字符串结构的多个子文件夹中与字符串匹配的文件复制到另一个目标文件夹 - Copy files matching string(s) in a text file out of many subfolders with folder structure to another destination folder Bat脚本可查找和替换多个子文件夹中的文件-将.java文件替换为特定文件夹中的.class文件 - Bat script to find and replace files in multiple subfolders - replace .java files with .class files from specific folder Windows 7 vs Windows 10-处理批处理文件中带有空格的文件夹名称 - Windows 7 vs Windows 10 - Handling folder names with spaces in batch files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM