Hi
I have data in filelist.TXT file as below.
"201804170930-ScottsDDSupplier.csv"
"201804180930-ScottsDDSupplier.csv"
"201804211030-ScottsDDSupplier.csv"
i need to sorting in Descending order when i read file as below..
@echo off
setlocal enableExtensions disableDelayedExpansion
set file=D:\filelist.txt
for /f "tokens=1 delims=" %%a in (%file% ) do (
echo %%a
)
so output should be like below ..
"201804211030-ScottsDDSupplier.csv"
"201804180930-ScottsDDSupplier.csv"
"201804170930-ScottsDDSupplier.csv"
how to handle with in batch script , please help
Sorting text file content with batch script,.
Moderator: DosItHelp
Re: Sorting text file content with batch script,.
The following might help you:
penpen
Code: Select all
@echo off
setlocal enableExtensions disableDelayedExpansion
set "file=D:\filelist.txt"
sort /r "%file%"
-
- Posts: 21
- Joined: 16 Aug 2019 23:35
Re: Sorting text file content with batch script,.
Thank you Penpen,
one more need help , not i need only first record return ?
"201804211030-ScottsDDSupplier.csv"
"201804180930-ScottsDDSupplier.csv"
"201804170930-ScottsDDSupplier.csv"
one more need help , not i need only first record return ?
"201804211030-ScottsDDSupplier.csv"
"201804180930-ScottsDDSupplier.csv"
"201804170930-ScottsDDSupplier.csv"
-
- Posts: 21
- Joined: 16 Aug 2019 23:35
Re: Sorting text file content with batch script,.
Please Help on this.
Re: Sorting text file content with batch script,.
If understand right, that there are (contrary to your opening post) mutliple records per line in your file "filelist.txt", then that might help you:
Code: Select all
@echo off
setlocal enableExtensions disableDelayedExpansion
set "file=D:\filelist.txt"
set "file=test.txt"
for /f ^"delims^=^"^" %%a in ('sort /r %file%') do (
echo "%%~a"
)
goto :eof
penpen
-
- Posts: 21
- Joined: 16 Aug 2019 23:35
Re: Sorting text file content with batch script,.
Thank you so much PenPen for your kind help.