1.

Solve : how to know free space on HD?

Answer»

Hi, I make a zip file of 1,5 Gb with a batch file but i need to know before if I have 1,5 Gb free space on HD.
How can I make by the batch command?
ThanksAnyone help me please... You didn't mention an OS, but you can give this a try:

@echo off
dir | find "bytes free" > dummy.txt
for /f "tokens=1-4" %%i in (dummy.txt) do (
if /i %%k GEQ "1,500,000,000" echo Enough Space
del dummy.txt
)

I arbitrarily used the echo statement. You can change it to launch your zip program.

Hope this helps. Thanks for a reply, I use XP pro ita, I substitute some parameters for italian OS but dont TELL me if i have Enough Space, I need to substitute "tokens=1-4"? Can you explane me the FOR cicle? Thanks

@echo off
dir | find "byte disponibili" > dummy.txt
for /f "tokens=1-4" %%i in (dummy.txt) do (
if /i %%k GEQ "1.500.000.000" echo Enough Space
del dummy.txt
)

The batch file every time tell me enough space
The FOR loop just reads the line of a DIRECTORY listing that was found; the one with how many bytes are free. We don't have to assign all four values delimited by spaces on that line, it's just easier when debugging.

@echo off
dir | find "byte disponibili" > dummy.txt
for /f "tokens=1-4" %%i in (dummy.txt) do (
if "%%k" GEQ "1.500.000.000" echo zip pgm goes here
del dummy.txt
)

I FORGOT the quotes around %%k. We have to do a string comparision because the bytes free is formated with dots.

Good luck. Thank you very much!!!
I found the compare signs: GTR, LSS, GEQ, EQU.
@echo off
dir | find "byte disponibili" > dummy.txt

for /f "tokens=1-4" %%i in (dummy.txt) do (
if /i "%%k" GTR "1.500.000.000" (
echo ok
echo "%%k"
del dummy.txt
) else (
echo KO
echo "%%k"
del dummy.txt )
)
I tried and work, but if I wont to compare with 15.000.000.000 why the results are ok and not ko? I need to change some parameters?The ELSE has to be on the same line as the command after the IF. I guess you can only do one command per IF statement. I made a small change to the earlier code snippet:

@echo off
dir | find "byte disponibili" > dummy.txt
for /f "tokens=1-4" %%i in (dummy.txt) do (
if "%%k" GEQ "1.500.000.000" echo zip pgm goes here
)
del dummy.txt

Maybe VB Script would be a better way to go with this.

Hope this helps. Thanks a lot for your help
I'm not able to make a VB script I can make in delphi but in dos is good because anyone can modify a script WITHOUT a source. The last pleasure....if you know a free programmer dos manual to download....
Thank you for help and sorry for my english ERROR I couldn't find any free downloads of a DOS manual (IBM and Microsoft are not known for their generosity). This site may help you out, but just searching for 'DOS Batch' will find all sorts of helpful hints. Of course if you have any problems, you can always post here. There are very knowledgable people in this forum.

http://www.robvanderwoude.com/

Good luck.

PS. My Italian is not so good either.



Discussion

No Comment Found