i have text file 1 string per line (only couple lines total). file needs searched , each string stored. script prompt user choose 1 of stored strings (if more 1 string/line present in file), loop iterating time when don't want to.
i'm using counter check number of iterations, , read it's nl cr regex issue, finstr /v /r /c:"^$"
in file-set in post batch file loop appears running 1 time/iteration doesn't work me (but don't understand correctly).
the "pref" term because strings used prefix of files in same folder...
@echo off setlocal enabledelayedexpansion set /a x=1 /f %%a in (sys.txt) ( set pref!x!=%%a && echo %^%pref!x!%^% && set /a x+=1 ) echo last value of x = !x! /l %%a in (1,1,!x!) ( echo !pref%%a! ) rem rest prompt user choose 1 (if multiple) , rem use choice prefix ren %%a %prefx%%%a
if "sys.txt" contains 3 lines strings a, b, c respectively, output is:
pref1 pref2 pref3 last value of x = 4 b c echo off.
echo off.
not desired, clearly.
you need change increment structure this. (set before each line starting base of 0)
@echo off setlocal enabledelayedexpansion set "i=0" /f "usebackq delims=" %%a in ("sys.txt") ( set/a "i+=1" set "pref!i!=%%a" echo(pref!i!) echo(last value of = %i% /l %%a in (1,1,%i%) echo(!pref%%a!
Comments
Post a Comment