How to create a Serial number for item attribute?

Hi there.

I have a photo printing business and need to serialize the printed photos that entered on stock, based on the photo code.

I use Photo as Template, attribute “size”(e.g. 20x10 cm, 30x10 cm, etc) and “art”(FG-01) and it results in something like “Photo-20x10cm-FG-01”. I want to track the serial number of all my FG-01 photos regardless the size. e.g. “Photo-20x10cm-FG-01” has the 01, 02, 03 and 04 serial but “Photo-30x10cm-FG-01” has the 10, 11, 12 serial of the “FG-01” art.

Thanks for your help in advance.