I have a function, explicit that takes dot product of two symbols, and replaces it with repeated dummy indices generated by Unique[].
explicit[expr_] :=
expr //. {Dot[a_, b_] :> (Subscript[a, #] Subscript[b, #]) &[
Unique[]]};
So that if my input is v.w, then the output is $v_{$3}w_{$3}$ which is good.
The problem is that if there is a single term multiplying two pairs of dot products, I don't know how to get Unique[] to generate a new symbol for each pair. That is, if I input c.d e.f the output is $c_{$3}d_{$3}e_{$3}f_{$3}$, which is bad. I want $c_{$3}d_{$3}e_{$4}f_{$4}$, with new repeated subscripts. How do I modify my code?

ReplaceRepatedhere but I left it in my answer since that wasn't the focus. – Mr.Wizard Mar 08 '13 at 03:52