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
pause

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.

Check Also

ping color

Bat file for continuous Ping with background Colour changes

We are using ping command to monitor the networks, Sometimes we have to monitor multiple …