Unfortunately, you don't mention any error messages, so all I can do is offer a few (I hope, constructive) criticisms.
set rootfolder="C:\Users\User\Desktop\mov"
set "clean=false"
The second format is usually preferred on this tag, so
set "rootfolder=C:\Users\User\Desktop\mov"
This allows the quotes to be easily inserted as and when necessary. It also protects against terminal spaces and tabs as you have in your code. As you have coded it, any trailing spaces or tabs would be included in the value assigned to rootfolder
and can cause chaos - hours of work caused by invisible characters. Once bitten, twice shy.
clean
is evidently being used as a Boolean. Personally, I'd suggest you look here for usage of Boolean variables. The advantage of this usage is that it works in code blocks
(parenthesised statements) without the need to invoke delayedexpansion
.
echo Enumerating all MKVs under %rootfolder%
for /r %rootfolder% %%a in (*.mkv) do (
%rootfolder%
in these two lines would require to be "quoted"
if NOT [%%s]==[0] (
hmm. remember that syntax if [not] string==string
if [%%b]gtr[1] (
Then apply here - where I believe your problem is resident.
This is of the format if string (
, so cmd
should object as the operator is invalid ((
)
The correct format would be
if [%%b] gtr [1] (
or preferably
if "%%b" gtr "1" (
or probably preferably
if %%b gtr 1 (
The issue here is gtr
(or any other member of the alphabetical-comparison-operator family) has no significance over any random alphabetic string. Consider if sequins equ acceptable (
for instance. sequins
is obviously neq acceptable
, but using the syntax you have used, it would be if sequinsequacceptable (
Should that be interpreted as if s equ insequacceptable (
or if sequins equ acceptable (
?
The second form is better. It allows strings containing spaces to be compared. BUT there's a gotcha. if "123" gtr "2"
would be evaluated as FALSE because the comparison is performed alphabetically; "1"
is less than "2"
so result is FALSE.
Hence the third form, which is valid for numeric comparisons (but will be interpreted as the string form if either of the operands is non-numeric).