Skip to content

Instantly share code, notes, and snippets.

Forked from bmcbride/
Last active August 14, 2020 01:27
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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.
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read -a csv_line
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"
REM This batch script appends first 10 characters of the value in the second column of the .csv (Fulcrum's `Created At` date value) to the front of the `fulcrum_id.pdf`
@echo off
setlocal enabledelayedexpansion
FOR /F "usebackq tokens=1,2 delims=," %%g IN (inspection_reinspection_count.csv) DO (
set sub=%%h
set sub=!sub:~0,10!
ren %%g.pdf "!sub!-%%g.pdf"
:: this Windows batch file will rename a folder of PDF's from the Fulcrum Exporter using a column from a CSV, typically exported from Fulcrum
:: copy this code and paste it into Notepad, save the text file to your extracted export folder with the extension .bat instead of .txt
:: edit line with "tokens=1,2". '1' is the fulcrum_id/_record_id column and the first CSV column probably don't want to edit this
:: '2' is the second column of the CSV ...update this with the column number which you want to rename the PDF to
:: edit 'rename.csv' to the name of your Fulcrum exported CSV
:: this script currently doesn't handle renaming-to values containing commas - you must manually remove them like with Find/Replace in Excel or similar
:: you may want to manually 'build' your own filename field in your app with a hidden Calculation field and/or Data Event
@echo off
setlocal enabledelayedexpansion
echo I will now try to rename things, shall we begin?
set /a counter=0
FOR /F "usebackq tokens=1,2 delims=," %%a IN (rename.csv) DO (
:: rename the fulcrum_id.pdf with the values in the 2nd column of the CSV
IF EXIST %%b.pdf (
ren %%a.pdf "%%b_!counter!.pdf"
) ELSE (
ren %%a.pdf "%%b.pdf"
:: next line is for debugging
:: echo %%a.pdf "%%b.pdf" >> results.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment