Created a sed script "fnum-to-pnum" that maps "f" page numbers (like f66r2) to sequential numbers 001-266. Note that missing pages are included too. gawk '/@/{n++; printf "%s p%03d\n", $1, n; next} /-/{print; next}'