1.

Solve : File Properties using batch?

Answer»

anyone know how i can use a batch file to look up the size\free space on a drive??Since I have to GUESS your OS, you have to guess if this will work for you:

Code: [Select]echo off
for /f "tokens=3" %%i in ('dir [highlight]c:[/highlight] ^| find /i "free"') do echo %%i

Feel free to change the drive letter.

 8-)thanks for responding siderwinder, i need to do it both on nt4 and xp, many thanks Quote

Code: [Select]echo off
for /f "tokens=3" %%i in ('dir c: ^| find /i "free"') do echo %%i


it works for me (Windows XP) but only if I write
for /f "tokens=3" %i in ('dir c: | find /i "free"') do echo %i

dir c: | find etc. is good
dir c: ^| find etc. isn't
what's with the "^|" syntax ?  :-?The caret (^) acts as a escape character when using DOS SPECIAL characters. I couldn't find much documentation on why you need it, just that without it under certain conditons the parser will error out.

Apparently you need to use it when a DOS special SYMBOL is used in a nested command.

In the example I gave you: for /f "tokens=3" %%i in ('dir c: ^| find /i "free"') do echo %%i, the pipe (|) is embedded in the FOR command.

I know, I know, not much of a response, but use it if you get an error by not using it.
Quote
The caret (^) acts as a escape character when using DOS special characters.
Apparently you need to use it when a DOS special symbol is used in a nested command.


I guess this shows why an expert is called an expert  [smiley=thumbsup.gif]

It's exactly as you said.
In a batch file, if I LEAVE the ^ out it breaks, if it's in, the parser itself will take care of it,
just the opposite at the command line.
A bit like doubling % in batch isn't it
I never had any idea it should work this way. Thanks a lot for the info  [smiley=vrolijk_26.gif]  [smiley=beer.gif]


Discussion

No Comment Found