soni
soni

Reputation: 59

Read each line in a txt file and assign variables using windows dos commands

I am copying the files from one path to svn working copy by comparing the those 2 folders using beyond compare commandline. Report will get generated after the comparison is done using beyond compare. If any extra files are present in the right side should get deleted from svn repsotiory. So I am using a below for loop to loop through that file. I want to use svn delete for all the right orphaned files in the txt file

FOR /F "tokens=* delims= usebackq" %%x IN (%TEXT_T%) DO (

echo %%x

)

Can you please let me know how can I assign the each line in the txt file and how can I apply svn delete command for that?

Any help would be appreciated

Upvotes: 3

Views: 5194

Answers (3)

Anthony Miller
Anthony Miller

Reputation: 15919

Steenhulthin's answer is correct. @SONI if you want to do it your way (which is a hard way... which is a little funny cause the computer's doing it for you anyways so it's not really hard at all =P ) You can do the following:

SETLOCAL EnableDelayedExpansion
SET count=1
FOR /F "tokens=* delims= usebackq" %%x IN ("%TEXT_T%") DO (
SET var!count!=%%x
SET /a count=!count!+1
)
ENDLOCAL

That way, you'll get

var1 = first string

var2 = second string

so on and so forth.

Upvotes: 1

steenhulthin
steenhulthin

Reputation: 4773

It sounds like what you really want is just:

FOR /F "tokens=* delims= usebackq" %%x IN (%TEXT_T%) DO (
svn delete %%x
)

Upvotes: 3

ghostdog74
ghostdog74

Reputation: 342313

you can set variables as you iterate the loop

Upvotes: 0

Related Questions