First thanks to the authors of the site, I learned many things here
I hope someone can help me for the following problem:
I have a script that browse *.txt files. They are sorted by name.
For each file, I read an indexpos (an integer from 0 to 100) given in the file.
Now, what I want to do is sorting filenames using their indexpos
(2 files can have the same indexpos)
e.g:
Code: Select all
files %indexpos% in the file
--------------------
"a.txt" indexpos=3
"b.txt" indexpos=4
"c.txt" indexpos=1
"d.txt" indexpos=3
"e.txt" indexpos=2
"f.txt" indexpos=3
a piece of code:
Code: Select all
the code looks like this:
for /f "usebackq delims=" %%i in (`dir /B /O:N "%presets_path%\*.txt"`) do (
:: get indexpos from the file (this works)
set indexpos=!data!
:: ... ???
)
:: sort filename...
and I wnat to display this:
Code: Select all
c.txt
e.txt
a.txt
d.txt
f.txt
b.txt
I have a solution that works using arrays but it does too many iterations. It is not optimized at all
Have a better idea?
Thanks for help