I could factor the terms as you wanted.
The behaviour of your session might be due to the properties
of your objects.
I took your (incomplete) example, and re-ensembled it like this:
{a,b}::Indices.
\partial{#}::PartialDerivative.
{A,B,C,D}::Depends(\partial{#}).
ex := \partial_{a}{A} B + A \partial_{a}{B};
rule := \partial_{b?}{C??} D?? + C?? \partial_{b?}{D??}
-> \partial_{b?}{C?? D??};
substitute(ex, rule);
Update
Physics Cat
thank you for highlighting that the extra factor of 2
was not a typo.
In your case, I'd follow Kasper's (usual) advise, and use the substitution the other way around,
rule2 := \partial_{b?}{C??} D?? -> - C?? \partial_{b?}{D??}
+ \partial_{b?}{C?? D??};
The whole notebook (MWE) would be:
{a,b}::Indices.
\partial{#}::PartialDerivative.
{A,B,C,D}::NonCommuting.
{A,B,C,D}::Depends(\partial{#}).
ex1 := \partial_{a}{A} B + A \partial_{a}{B};
rule := \partial_{b?}{C??} D?? + C?? \partial_{b?}{D??}
-> \partial_{b?}{C?? D??};
substitute(ex1, rule);
ex2 := \partial_{a}{A} B + 2 A \partial_{a}{B};
rule2 := \partial_{b?}{C??} D?? -> - C?? \partial_{b?}{D??}
+ \partial_{b?}{C?? D??};
substitute(ex2, rule2);
Hope this could be of use!