File generator in shell script
Automated suggestions

If you don't have shellcheck installed, grab it, or use the online service.  It reports a bunch of questionable constructs:

202986.sh:4:1: warning: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. [SC2164]
202986.sh:6:38: note: read without -r will mangle backslashes. [SC2162]
202986.sh:8:22: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:10:9: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:12:10: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:12:61: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:12:84: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:14:15: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:14:41: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:14:68: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:16:11: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:16:22: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:16:51: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:18:8: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:19:8: note: Double quote to prevent globbing and word splitting. [SC2086]
202986.sh:23:7: note: Use $(..) instead of legacy `..`. [SC2006]
202986.sh:25:7: note: Use ./*glob* or -- *glob* so names with dashes won't become options. [SC2035]
202986.sh:25:24: note: Double quote to prevent globbing and word splitting. [SC2086]


Prefer lower-case for variable names

We normally use upper-case names for environment variables intended to change the behaviour of programs we use.  It's better to use lower-case for ordinary shell variables.

Check for program failure

At present, if compilation fails, we'll still proceed, likely with old code.  Instead, we should abort execution if any of the steps fail.  It's pretty easy to ask the shell to do this for us (though it's worth learning the exceptions); we can also ask it to check we don't expand any undefined variables, too:

set -eu


Useless use of xargs

I've never seen this pattern before:

echo "$filename" | xargs program


Unless your filename contains whitespace (the rest of the code implies it doesn't), that's exactly

program "$filename"


Unusual date conversion

Do you really mean to give the result file a name given by day-within-year and minute-within-hour?  That's a surprising combination, and certainly deserves a justifying comment if it is really what you want.

Avoid temporary files

Pipeline processing can produce results with lower latency than storing intermediates to temporary files.  We can pipeline one input into pdftk and create the other using a process substitution in roughly this manner:

enscript "$CPPFILE" | ps2pdf \
    | pdftk - &lt;(./a.out | enscript | ps2pdf) \
            cat output "$TITLE.final.pdf"


Consider using Make

If you make a change to a single file, you need to re-run the script (re-doing all the compilation and output processing) to update the final output.  Make is more intelligent: you can write pattern rules that enable you to re-build and re-run only what's out of date, without wasting time and energy on the bits that haven't changed.

It can also clean up the temporary files, and you could write a "clean" rule to clean up all the result files.

If you do write a Makefile, be sure to bring it here for review!