繁体   English   中英

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

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

我有一个包含110.000个文件的文件夹,并且我想要一种将该文件夹分成多个子文件夹的方式,每个子文件夹包含3000个文件(也许有批处理脚本?)。 (使用WinExplorer尝试复制/粘贴会陷入“准备复制”中。)

例如:

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

我很惊讶地发现我的同样情况。 我有30,000个需要排序的文件,所以我在此页面上问了一个问题: 在批处理文件中复制(移动)文件的快速方法

这是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 

这就是我使用的目的,为此我做了一些编辑:

@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

您可以根据需要删除taskkillstartsc part。 我添加此部分是因为资源管理器和Windows搜索索引器将在移动文件时浪费内存。 我建议您以管理员权限运行脚本。

尝试以小规模测试脚本以查看其是否有效。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM