# Bash rename PDFs # Working fiddle: https://regex101.com/r/rQ9lX1/1 # Note: $(< "$f" wc -l) is the suffix with a word count [fairly random!] # Note: Remove '-n' is the result is as expected for f in *.pdf; do rename -n "s/([^.]+)(\.?.*)/\$1_$(< "$f" wc -l)\$2/" "$f"; done