Jump to content

Read a from a text file, set as a variable


Recommended Posts

Posted

Possibly a simple task but I can't seem to find out how to do this! Two files:

 

Drive.txt

Command.bat

 

Drive.txt simply contains "D:"

 

How can I get the batch file to read "D:" in the drive.txt file and set it as a variable? :confused:

Guest TheLibrarian
Posted
The for command is your friend there.
Guest TheLibrarian
Posted
Thanks guys! One last search in Google pulled this up:

 

set /p Drive=

 

Seems to work a treat. :)

 

That will work as long as you don't have a requirement for processing more than one line.

Posted
That will work as long as you don't have a requirement for processing more than one line.

 

Nope, it will only ever be one line, but I can see this being useful so will explore the for command a bit more too. :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...