How to check the size of a file in a path with spaces in a batch script -


i found answer here: how can check size of file in windows batch script? , works if file path without spaces not if has spaces

example:

set file=c:\example.txt /f "usebackq" %%a in ('%file%') set size=%%~za 

works

set file=c:\program files\example.txt /f "usebackq" %%a in ('%file%') set size=%%~za 

not, tried double quote path in variable declaration

set file="c:\program files\example.txt" 

and/or in loop file variable

for /f "usebackq" %%a in ('"%file%"') set size=%%~za 

but none works

set "file=c:\program files\example.txt" %%a in ("%file%") set "size=%%~za" 

there no need for /f command (its normal use process file contents or strings or output of command execution), basic for command grab reference file enough.


Comments