Hello all my first post here, Im having a little trouble with a script im working on. Specifically, i need to know how to pass the info in a text file to a variable i create, I am somewhat new to batch scripting and i have tried everything but i just cant seem to figure it out.
This script will only be used in the windows XP console.
For an example, in it's simplest form this is what im after, i can probably take it to more complicated levels once i know how to do it:
:: output something from the console then send to txt file
DIR | Find "bytes free" > bytes.txt
:: asign the string inside the text file to a variable
SET BYTES = "the string inside bytes.txt"
::display the value of the string
echo %BYTES%
do you even need the intermediate text file? is this even possible?
Help with passing variable
Moderator: DosItHelp
dsumanik,
No intermediate file needed.
Try:
Optionally use this function:
http://www.dostips.com/DtCodeCmdLib.php#kBytesFree
DOS IT HELP?
No intermediate file needed.
Try:
Code: Select all
FOR /f "tokens=3 delims= " %%a in ('"dir|find "bytes free""') do set free=%%a
echo.%free%
Optionally use this function:
http://www.dostips.com/DtCodeCmdLib.php#kBytesFree
DOS IT HELP?