Solved extra stuf in a txt file

November 13, 2011 at 18:09:03
Specs: Windows 7
I made a batch file to calculate free space:
dir C:\|find /i "bytes free" >> drivespacefree.txt
but the out put looks like this:
9 Dir(s) 917,408,808,960 bytes free
I need it to look like this:
and then reed that number into a variable %freespace%
then clear the txt file
can someone help me?

See More: extra stuf in a txt file

Report •

November 13, 2011 at 18:56:28
✔ Best Answer
Please test this script. The file is not needed so not created.

@echo off
setlocal enabledelayedexpansion 

for /f "tokens=3" %%1 in ('dir C:\ ^| find /i "bytes free"') do (
    set freespace=%%1&set freespace=!freespace:,=!
echo %freespace%

Please come back & tell us if your problem is resolved.

Report •

November 14, 2011 at 08:25:07
thankyou, it works perfictly. you even used the same variable name so I just copyed and pasted it into my program and it works perfictly.

Report •

Related Solutions

Ask Question