I have a windows directory full of txt files, all numbered consecutively (example: f1,f2,f3, etc) there are more than 2 million of them, what I need is a script that copies every 400 files and creates a folder with a numeric name (example: folder1, folder2, folder3, etc), to copy the next 400 files, I have the following script, the problem is that it copies everything to a single folder that it creates
@echo off
rem COUNT
set c=0
rem FOLDER ID
set f=0
mkdir folder%f%
echo Copiando a folder%f%...
for %%i in (*) do (
if %%c LSS 400 (
rem COPY TO CURRENT FOLDER
copy %%i folder%f%\
rem INCREASE ITERATION COUNT
set /a c+=1
) else (
rem INCREASE FOLDER ID
set /a f+=1
rem ADD A NEW FOLDER
mkdir folder%f%
echo Copiando a folder%f%...
rem RESET ITERATION COUNT
set c=0
)
)
I have created this script that is in charge of ordering the f%numero%.txt files in 400 by 400 folders numerically, I hope it helps you.