Advertisement
theitd

Bash rename

Jan 18th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.27 KB | None | 0 0
  1. # Bash rename PDFs
  2. # Working fiddle: https://regex101.com/r/rQ9lX1/1
  3. # Note:  $(< "$f" wc -l) is the suffix with a word count [fairly random!]
  4. # Note: Remove '-n' is the result is as expected
  5.  
  6. for f in *.pdf; do rename -n "s/([^.]+)(\.?.*)/\$1_$(< "$f" wc -l)\$2/" "$f"; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement