Computing.Net > Forums > Programming > create vars from txtfile with multiple lines

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

create vars from txtfile with multiple lines

Reply to Message Icon

Name: hgy345
Date: November 5, 2009 at 11:17:03 Pacific
OS: Windows XP / 2003
Subcategory: Batch
Comment:

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!



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: November 5, 2009 at 12:32:16 Pacific
Reply:

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!


1

Response Number 2
Name: hgy345
Date: November 6, 2009 at 08:08:51 Pacific
Reply:

thx!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: create vars from txtfile with multiple lines

deleting multiple lines in multiple text file www.computing.net/answers/programming/deleting-multiple-lines-in-multiple-text-file/19862.html

creating var containing 8 random digits www.computing.net/answers/programming/creating-var-containing-8-random-digits/20261.html

Print multipl lines in a cell in VB www.computing.net/answers/programming/print-multipl-lines-in-a-cell-in-vb/4945.html