How do you execute these types of programs?

How do you execute these types of programs? Let’s say the output of file A is “ab?.p” and that of B is “12?01.” I want the output of file C to be based on files A and B, using something like interleaving technique (“a1b2??.0p1”) and file D to have an output based on the three files (“a1a1b2b2???”).
