theitd icon

Bash rename

theitd | PRO | 01/18/19 08:36:59 AM UTC | 0 ⭐ | 529 👁️ | Never ⏰ | []
Bash |

270 B

|

None

|

0 👍

/

0 👎

# 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

Comments