0

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

4

1 回答 1

0

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

于 2013-02-10T14:50:09.490 回答