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, I Blog about technology related articles, Active in online and offline tech communities

Leave a Reply

More in Programming (7 of 10 articles)