Skip to content

Instantly share code, notes, and snippets.

@bmcbride
Last active July 22, 2016 00:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bmcbride/a132702fc0c0805db62b to your computer and use it in GitHub Desktop.
Save bmcbride/a132702fc0c0805db62b to your computer and use it in GitHub Desktop.
Fulcrum PDF reports are named with the record's unique fulcrum_id. This bash script loops through the parent CSV file and renames the PDF files based on the index of user-specified fields.
#!/bin/bash
INPUT=fire_hydrants.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read -a csv_line
do
mv ${csv_line[0]}.pdf ${csv_line[8]}-${csv_line[0]}.pdf
done < $INPUT
FOR /F "usebackq tokens=1,2,26 delims=," %a IN (fire_hydrants.csv) DO ren %a.pdf "%c.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment