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.
variable inside for-loop( batch )
Name: taiwf Date: September 22, 2005 at 17:58:53 Pacific OS: win2k CPU/Ram: p4 celeron/512Mb
Comment:
I am try to access a environmental variable i SET inside the batch for loop. But i can't seem to acess it even tho its actually already existed (i pause the forloop and test it on anther cmd screen). Can anyone please help me about it?
Below is the script.
:: I name my usb hard disk with bracket, ie.(hard-disk-Name) ::-----------------------
for /f "token=2 delmis=(*)" %%A IN ('vol e: f: g: 2^>NUL') do ( SET hd_name=%%A echo %hd_name% )
Name: Mechanix2Go Date: September 22, 2005 at 20:38:58 Pacific
Reply:
I couldn't make yours work, so I re-wrote it.
Note that the variable is NOT available in a different command shell.
HTH
::::::::: @echo off
for /f "tokens=*" %%A IN ('vol c: e: u: ^|find "drive"') do call :sub1 %%A goto :eof
:sub1
SET hd_name=%6 echo %hd_name% goto :eof :::::::::::::::
If at first you don't succeed, you're about average.
M2
0
Response Number 2
Name: taiwf Date: September 22, 2005 at 22:37:38 Pacific
Reply:
I think the problem is whenever i try to do arithmatic inside () , it just won't work!
I try this and somehow the line outside bracket give me correct answer and inside 1+1 always give me 1 not 2...
SET ROT_COUNTER=1 if %ROT_COUNTER% LEQ 2 ( SET /a ROT_COUNTER=%ROT_COUNTER%+1 echo "ROT_counter less or equal to 2" echo %ROT_COUNTER% ) else ( SET /a ROT_COUNTER=1 echo %ROT_COUNTER% )
Summary: I created a simple batch job that reads the third line in a file and sets the third line to a variable. the code works, it is: @echo off set rep=0 set report=0 for /F "usebackq delims=" %%r in ("%%a")...
Summary: Hi, I try to catch the empty string present in for loop but somehow it never does the job... Basically i try to search sth thats not existed and i put a "" around that variable which suppose to give...
Summary: for %f in ( *.ctl ) do set d1=%f echo %d1~1,2% this gives the last file number, as i cut the file number positioned at 2nd 3rd place. I want to cut all the file number stratung from 1 and then my aim ...