gre*_*tor 3 windows-explorer batch-file windows-10
我有一个包含 110.000 个文件的文件夹,我想要一种方法将这个文件夹分成多个子文件夹,每个子文件夹包含 3000 个文件(也许有批处理脚本?)。(尝试使用 WinExplorer 进行复制/粘贴会卡在“准备复制”中。)
例如:
BigFolder
|
NewFolder
| | | | |
Sub1 Sub2 Sub3 Sub4 Sub5...
Run Code Online (Sandbox Code Playgroud)
我很惊讶地发现和我的情况一样。我有 30,000 个文件需要排序,所以我在这个页面上提出了问题: Fast methods to copy(move) files in batch file
这是Compo的脚本:
Run Code Online (Sandbox Code Playgroud)@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
Run Code Online (Sandbox Code Playgroud)
如果需要taskkill,您可以删除,start和scpart 。我添加这部分是因为资源管理器和 Windows 搜索索引器在移动文件时会造成内存浪费。我建议您以管理员权限运行脚本。
尝试小规模测试脚本,看看它是否有效。