SoFunction
Updated on 2025-04-09

Bat code that classifies files in the directory by extension

In fact, it is to use powerful for commands to implement

Implementation code:

Copy the codeThe code is as follows:

for %%i in (*) do (md %%~xi
move *%%~xi %%~xi)
pause

%~xI           -Extend %I to only one file extension
Print only file extensions
FOR /F "delims==" %%i IN ('dir /b') DO @echo    %%~xi
pause