[英]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. 您可以根据需要删除
taskkill
, start
和sc
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.