create vars from txtfile with multiple lines

November 5, 2009 at 11:17:03
Specs: Windows XP / 2003
I want to create vars from txtfile with multiple lines..

txtfile (directories.txt) looks like..

C:\test\00010010
C:\test\00010020
C:\test\00010030

(dir %1 /AD /B /S > directories.txt)..

I want to make a var per line in my batch script

another solution could be to create the vars directly instead of producing the txtfile..?

anyone? and thanks in advance!


See More: create vars from txtfile with multiple lines

Report •


#1
November 5, 2009 at 12:32:16
Begin your batch by coding

@echo off & setlocal EnableDelayedExpansion

then

set N=0
for /F "delims=" %%j in ('dir "%~1" /AD /B /S') do (
  set /A N+=1
  set var!N!=%%j 
)

for /L %%j in (1 1 %N%) do echo.!var%%j!


Report •

#2
November 6, 2009 at 08:08:51
thx!

Report •

Related Solutions


Ask Question