Bat file to get File size in human readable format

July 15th, 2010 | Your thoughts are welcome | Posted in Programming

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

Leave a Reply 487 views, 4 so far today |

Author : Albin Sebastian

I am a Technology Blogger, I Blog about technology related articles, Active in online and offline tech communities

Leave a Reply

CommentLuv Enabled