@ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET "sourcedir=C:\Users\Ufficio\Desktop\temp" SET "destdir=C:\Users\Ufficio\Desktop\temp2" SET /a destcount=0 SET /a maxcount=500 SET /a filecount=maxcount FOR /f "delims=" %%a IN ( 'dir /b /a-d "%sourcedir%\*" ' ) DO ( SET /a filecount +=1 IF !filecount! geq %maxcount% ( SET /a filecount=0 SET /a destcount +=1 MD "%destdir%\folder!destcount!" ) COPY "%sourcedir%\%%a" "%destdir%\folder!destcount!\" ) GOTO :EOF