@echo off set argpath= set arglist= set tmpfile="%~dp0arg.tmp" set output="%~dp0list.txt" call >%output% @(for %%a in (%*) do @echo "%%~dpa" "%%~fa")|sort /o %tmpfile% for /f "usebackq delims=" %%b in (%tmpfile%) do call :sub1 %%b call :sub2 del %tmpfile% exit /b
:sub1 if not defined argpath ( goto :jump ) if %argpath%=="%~dp2" ( set arglist=%arglist% %2 exit /b ) call :sub2 :jump set argpath="%~dp2" set arglist=%2 exit /b