Supposing you had a file attachment control bound to /my:myFields/my:group1/my:group2/my:fileField, where my:group2 is a repeating group, you can find the total number of file attachments in the group with
count(/my:myFields/my:group1/my:group2/my:fileField)
Note that this is only for explication and you don't have to type this all by hand. In the InfoPath expression builder, you would just click "Insert Function...", select count, double-click the underlined part and select the attachment's field.
This would also count the number of file attachments where a file isn't attached, so to count only the attachments that have a file attached, you can use:
count(/my:myFields/my:group1/my:group2/my:fileField[. != '']) <-- note these are two single quotation marks '', not one double quotation mark "
You could also apply the "cannot be blank" property to the fields to ensure that they all have a file attached. Now if you want to add up the counts of file attachment fields in several repeating groups, you can sum them all up in an eval function,
xdMath:Eval(., "count(my:group1/my:group2/my:fileField1[. != ''])+count(my:group3/my:group4/my:fileField2[. != ''])+count(my:group5/my:group6/my:fileField3[. != ''])")
Note that in this case, the node paths do not begin with a forward slash, because they are all relative to the starting node (just a dot here, indicating the root node.).
You won't need to worry too much about the details if you use the buttons and dialogs to insert the functions and nodes.