Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do note that batch only works with integers. Several of your calculations would result in a value of 0 MBs. Here is a <strong>rough example</strong> of how to work with decimal values.</p> <pre><code>@echo off call :Parse &gt; Newoutput.txt exit /b 0 :Parse for /f "tokens=1,2" %%A in (Output.txt) do call :ToMB "%%~B" "%%~A" || echo(%%A %%B exit /b 0 :IsNumber &lt;String&gt; for /f "delims=0123456789" %%A in ("%~1") do exit /b 1 exit /b 0 :ToMB &lt;String&gt; &lt;Name&gt; setlocal call :IsNumber "%~1" || exit /b 1 set "Number=%~1" set /a "Number/=1024" set /a "Decimal=Number" set /a "Number/=1024" set /a "Decimal-=(Number * 1024)" set /a "Decimal=(Decimal * 1000) / 1024" set "Decimal=000%Decimal%" set "Number= %Number%" set "Name=%~2 " echo %Name:~0,12%%Number:~-3%.%Decimal:~-3% endlocal exit /b 0 </code></pre> <hr> <ul> <li>Update: Added the AppName to the output along with <em>some</em> formatting. (Above)</li> <li>Update: Added Newoutput.txt redirect example. (Above)</li> <li>Update: Added conversion support for all tokens and improved formatting. (Below)</li> <li>Update: Added first line skip fix for the find command. (Below)</li> </ul> <hr> <pre><code>@echo off call :Parse &gt; Newoutput.txt exit /b 0 :Parse setlocal for /f "tokens=1,* delims=]" %%A in ('type "Output.txt" ^|find /n /v ""') do ( for /f "tokens=1,2" %%X in ("%%~B") do call :Convert "%%~X" "%%~Y" call :Blank "%%~B" ) endlocal exit /b 0 :Blank &lt;String&gt; set "String=%~1" if not defined String echo. exit /b 0 :IsNumber &lt;String&gt; for /f "delims=0123456789" %%A in ("%~1") do exit /b 1 if "%~1"=="" exit /b 2 exit /b 0 :Convert &lt;String&gt; &lt;String&gt; call :Calculate "%~1" Y || call :Display "%~1" Y call :Calculate "%~2" || call :Display "%~2" echo. exit /b 0 :Calculate &lt;Number&gt; [Pad] call :IsNumber "%~1" || exit /b 1 set "Number=%~1" set /a "Number/=1024" set /a "Decimal=Number" set /a "Number/=1024" set /a "Decimal-=(Number * 1024)" set /a "Decimal=(Decimal * 1000) / 1024" set "Decimal=000%Decimal%" set "Number=000%Number%" call :Display "%Number:~-3%.%Decimal:~-3%" %2 exit /b 0 :Display &lt;String&gt; [Pad] set "String=%~1" set "Pad=%~2" if defined Pad set "String=%String% " if defined String set /p "=%String:~0,24%" &lt;nul exit /b 0 </code></pre> <hr> <ul> <li>Update: Added PowerShell to Calculate routine to handle values up to 2^64 (Below)</li> </ul> <hr> <pre><code>:Calculate &lt;Number&gt; [Pad] call :IsNumber "%~1" || exit /b 1 set "Number=" set "Decimal=" for /f "tokens=1,2 delims=." %%A in ('"PowerShell %~1 / ( 1024 * 1024 )"') do ( set "Number=%%A" set "Decimal=%%B000" ) call :Display "%Number%.%Decimal:~0,3%" %2 exit /b 0 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload