Quantcast
Channel: Active questions tagged windows - Super User
Viewing latest article 23
Browse Latest Browse All 11428

Windows, how to convert batch program output of bytes to KB, MB or GB?

$
0
0

In windows batch, How to convert Bytes to KB or MB or GB?
In batch, How to output results to screen?

Below is a Windows batch that outputs a folder size in bytes.
example:
2,041,737,167 bytes in d:\temp

@echo off    set bytes=    for /f "usebackq tokens=1,2,3,4" %%a in (`dir /s/w/c "d:\temp\" ^| findstr "File(s)"`) do set bytes=%%c    echo %bytes%  bytes in d:\temp\*.*    pause    

In batch, how to convert?
2,041,737,167 bytes to:

1,993,883 KB (2,041,737,167 / 1024)
1947 MB (2,041,737,167 / 1048576)
1.9 GB (2,041,737,167 / 1073741824)

--


Viewing latest article 23
Browse Latest Browse All 11428

Trending Articles