Interest Ask. I do not know what size on disk is a property of any script object. You can calculate it by receiving files modulo bytes per cluster, subtracting this modulo from the file size, and then adding the cluster size. ( Edit: or use a more efficient Aacini calculation, which I'm still trying to understand.)
@echo off setlocal for %%I in (Testfile.txt) do ( set "fs=%%~zI" for /f %%J in ( 'wmic volume where "driveletter='%%~dI'" get blocksize /value' ) do 2>nul set /a %%J ) echo Size: %fs% set /a ondisk = ((fs-1)/blocksize+1) * blocksize echo Size on disk: %ondisk%
Many websites claim that fsutil fsinfo ntfsinfo DRIVE: is the best way to get bytes per cluster. It seems that this method is fraught with danger, with different labels depending on the language and different number of lines for different versions of Windows. In addition, Marged says, fsutil requires a boost. This WMI method works more universally and does not require administrator rights.
Thanks to JosefZ, Marged and Aacini for all your data!
source share