Computing.Net > Forums > Disk Operating System > Read file, put value to a variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Read file, put value to a variable

Reply to Message Icon

Name: Roger
Date: August 19, 2003 at 23:56:11 Pacific
OS: w2k
CPU/Ram: 1,44
Comment:

File "testfile" contains only one row with the name of another file "testfile2".
I want to put the name of "testfile2" (example 200308190000) into a variable.
How to write a BAT file that reads "testfile" and put the name of "testfile2" into a variable that I can use ? For example to copy "testfile2" to another directory.



Sponsored Link
Ads by Google

Response Number 1
Name: lode
Date: August 22, 2003 at 19:08:46 Pacific
Reply:

I don't know, but there are plenty of examples on the net, you should search for it. The FIND command will search for a text string in a file:

find "string" [path:filename]

Then you can use SET to assign a variable, refered to like:

set var=3
echo %var%

And you can also use CALL to read the commands from another batch file, but I don't know if it works with a text file:

call [path:filename]

That's just a few suggestions, you can find much more at various sites.


0
Reply to Message Icon

Related Posts

See More


Epson Equity LT combining files DOS



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Read file, put value to a variable

Redirecting text file to a variable? www.computing.net/answers/dos/redirecting-text-file-to-a-variable/3566.html

date Value in a variable in format www.computing.net/answers/dos/date-value-in-a-variable-in-format-/13474.html

Assign current date to a variable www.computing.net/answers/dos/assign-current-date-to-a-variable/10891.html