Would you look what's wrong with the file. can you as well attach an image with the output setlocal DisableDelayedExpansion ( for /F "tokens=1-6 delims= " %%A in (data.txt) DO ( set "par1=%%A" set "par2=%%B" set "par3=%%C" set "par4=%%D" set "par5=%%E" set "par6=%%F" setlocal EnableDelayedExpansion ) ) > data.txt.tmp REM ** Now sort the first colum, but echo only the rest of the line for /F "usebackq tokens=2* delims= " %%B in (`sort /r data.txt.tmp`) DO ( echo(%%A %%B %%C %%D %%E %%F) ) endlocal The text file : ID Name Weight Long Class Age 012 Eric 56 156 7 13 045 Richard 78 178 9 17 098 Maya 60 164 10 16 072 Anna 56 152 8 14 034 Helena 76 169 11 18 022 Kevin 66 162 6 12 093 Peter 99 170 12 19
Would you look what's wrong with the file.
can you as well attach an image with the output
setlocal DisableDelayedExpansion
(
for /F "tokens=1-6 delims= " %%A in (data.txt) DO (
set "par1=%%A"
set "par2=%%B"
set "par3=%%C"
set "par4=%%D"
set "par5=%%E"
set "par6=%%F"
setlocal EnableDelayedExpansion
)
) > data.txt.tmp
REM ** Now sort the first colum, but echo only the rest of the line
for /F "usebackq tokens=2* delims= " %%B in (`sort /r data.txt.tmp`) DO (
echo(%%A %%B %%C %%D %%E %%F)
)
endlocal
The text file :
ID Name Weight Long Class Age
012 Eric 56 156 7 13
045 Richard 78 178 9 17
098 Maya 60 164 10 16
072 Anna 56 152 8 14
034 Helena 76 169 11 18
022 Kevin 66 162 6 12
093 Peter 99 170 12 19
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images