Bat file to get File size in human readable format

There is an example of Bat file which can give output of file size in human readable format (Value with KB / MB etc ). This bat file is good with some copying / backup bat files. Here you will get the file size in variable called %size% . You can test the script by giving and input variable for %file%.

echo off
set /p file= Type your file name :
for /f "tokens=4 " %%a in ('dir /a-d/-c %file% ^| findstr /e %file%') do set size=%%a
set /a KB=(%size%/1024)
echo %KB% KB
set /a MB=(%size%/1024)/1024
Echo %MB% MB

About Albin Sebastian

I am a Technology Blogger, System Administrator by profession and webmaster by passion. Technology blogger, Active in Online and offline tech communities.

Leave a Reply

Read previous post:
PL/SQL Fundamentals

In my last article we were discussing about a few points related to the origin of the computer era. In...