@echo off
for /f "tokens=2,3" %%i in ('p4 labels') do echo %%j %%i >>tmp.txt
set /a n=10
set /a m=0
sort /r <tmp.txt >tmp1.txt
echo [Labels]>Labels.txt
for /f "tokens=1,3 delims=: " %%i in ('findstr /n . tmp1.txt') do (
set row=%%i
set "str=%%j"
cmd /v:on /c if !row! LEQ %n% echo Label!m!=!str! >>Labels.txt
set /A m+=1
)
del tmp.txt /f /q
del tmp1.txt /f /q
start Labels.txt
for /f "tokens=2,3" %%i in ('p4 labels') do echo %%j %%i >>tmp.txt
set /a n=10
set /a m=0
sort /r <tmp.txt >tmp1.txt
echo [Labels]>Labels.txt
for /f "tokens=1,3 delims=: " %%i in ('findstr /n . tmp1.txt') do (
set row=%%i
set "str=%%j"
cmd /v:on /c if !row! LEQ %n% echo Label!m!=!str! >>Labels.txt
set /A m+=1
)
del tmp.txt /f /q
del tmp1.txt /f /q
start Labels.txt