Q:

file name with Space causing missing operand

Attempting to make a batch to display the filesize of a file.
I have found an (almost) perfect solution in another post (How can I check the size of a file in a Windows batch script?) but whenever I enter a filename with a space, I get "missing operand" on the "FOR" line
I have implemented in a batch like this:
echo off
set /p title="Enter Film title: " %=%
set sum1=0
set fname="C:\Users\Public\Videos\ripped\%title%.mkv"
FOR /F "usebackq" %%A IN ('%fname%') DO set size=%%~zA
set /a sum1=%size%/1000000
echo Finished %title%.mkv, Size %sum1%Mb

So, for example, [Royals] works, but [True Lies] doesnt.  I've tried several combinations of quote marks etc but cant get it to work. Probably missing something small but can anyone help?
Thanks
Rob

A:

try FOR /F "usebackq tokens=*" %%A IN ('%fname%') DO set size=%%~zA

