If all file names follow this format (iteration number is preceded by App.in.), then just do something like
inPrefix = 'App.in.';
outPrefix = 'App.out.';
currInFilename = 'App.in.50';
currIteration = currInFilename(length(inPrefix)+1:end);
currOutFileName = [outPrefix currIteration];
We rely on the fact that all current iteration files are prefixed with App.in. so we just remove all of this from currInFilename by considering the substring from the index that follows this prefix (so length(inPrefix)+1) to the end of the string in order to extract the iteration number. We then concatenate that string with the output prefix to get
currOutFileName =
App.out.50