@ECHO OFF
SETLOCAL
SET "sourcedir=c:\sourcedir"
SET "destdir=c:\destdir"
SET /a numbertomove=20
FOR /f "tokens=1*delims=:" %%a IN (
'dir /b /a-d /o-d "%sourcedir%\*.jpg"^|findstr /n "."'
) DO (
IF %%a leq %numbertomove% ECHO MOVE "%sourcedir%\%%b" "%destdir%\"
)
GOTO :EOF
The required MOVE commands are merely ECHO
ed for testing purposes. After you've verified that the commands are correct, change ECHO MOVE
to MOVE
to actually move the files. Append >nul
to suppress report messages (eg. 1 file moved
)
Edited to remove self-scheduling.