Automatically Rename PDF Files via a Text Search
Introduction
PDF filenames often need to be replaced if they do not properly reflect the content of the document. Doing this manually for many similar files can be time consuming. Use this method to search for text located within each document such as account numbers, client names/numbers or dates etc. and use it to replace filenames. The AutoSplit™ plug-in for Adobe® Acrobat® can be used to automatically rename multiple files at once, following a specified configuration that uses text from within documents following the same format.
Input Document Description
The sample files used here are invoices named only by each customer name. The goal is to rename these PDF files so they include more relevant information such as an “Invoice Number” or invoice date. This information is located on the first page of each document. Such file names may be more useful when used by an accounting department or being archived for future use.
Renaming Approach
Each invoice has an invoice number and a date located somewhere on the first page. The plug-in can be used to search each document for this text, and use it as part of the replacement filenames. The configuration can also be saved so that more files can later be renamed using the same method. The necessary text is going to be extracted via a text search, using regular expression syntax. Use this method when the required text always features in each document to be renamed. Regular expressions can be modified to change how this text is extracted and used in the resulting filenames.
Batch Processing Support
Automate this operation with Acrobat's batch processing tool (Action Wizard) to process similar files using the same configuration with only one click.
Prerequisites
You need a copy of Adobe® Acrobat® along with the AutoSplit plug-in installed on your computer in order to use this tutorial. You can download trial versions of both Adobe® Acrobat® and AutoSplit™.
Step 1 - Open the “Auto-Rename PDF Files” Menu
Close all PDF documents open in Acrobat to avoid possible file access conflicts. Start Adobe® Acrobat® and select “Plug-ins > Auto-Rename PDF Files…” from the main Acrobat menu.
Step 2 - Add a New Filename Component
Press “Add…” to add a new component to the output file name.
Step 3 - Select a Filenaming Option
Select the “Text By Search” option and click “Next” to enter parameters.
Step 4 - Enter a Search Expression
In the "Find Text" dialog, configure search parameters for locating text within documents that is to be used as a filename component. Enter a relevant search expression in the "Find what:" entry box. In this example, we'll use the expression "Invoice number: \d+" to extract invoice numbers from each invoice, to be used as filenames. These numbers are always located on the first page of each document.
This expression consists of the text to search for ("Invoice number:") which is followed by a number consisting of one or more digits ("\d+"), with the "+" indicating 'one or more' as the invoice numbers may vary in length.
This expression will also extract the "Invoice number:" text as well as the corresponding number. As ":" is not a permitted symbol for use in filenames, they are automatically replaced with an underscore "_".
It is also possible to extract only the invoice number itself (e.g.: "123456789") without the "Invoice number:" text by changing the expression to "Invoice number: \K\d+".
To extract dates and use them to name documents in the same way, use either:
"Date: [\d/]+"
Or, "Date: \K[\d/]+" to include numerical data only and not the "Date:" text. In these examples below, the client name data has also been used as a filename component. Each slash "/" has also been auto-replaced by an underscore "_".
Step 5 - Confirm Search Expression Options
Confirm necessary options such as "Match whole words only" or "Match case" - in this example, both are left unchecked ("Invoice number/date" text is uppercase in these sample documents, but the expression would still work if the text case was inconsistent across all files being renamed).
Optionally, add components to search expressions via the "Add Search Item..." button. This opens a dialog containing a detailed list of template search items that can be selected according to the user's requirements.
Click "OK" to proceed.
Step 6 - Configure Further Options
The text search filenaming component will now be listed. Repeat the procedure to add more (e.g.: add custom text to each filename) and use the additional buttons to add/edit/remove components. The blue arrow buttons can be used to re-order components.
The plug-in also allows the user to replace or remove certain characters from the new filenames. To do this, click on the "Options..." button to specify a renaming "rule".
Step 7 - Confirm/Save Renaming Options
Use the "Save Settings..." button to save this configuration as a *.docren settings file for future re-use. This can be loaded via the "Load Settings..." button.
There is also the option to save renamed files in a separate location, instead of replacing existing files. To do this, check the "Move successfully renamed files to another folder" option. This activates the "Select Output Folder..." button. Press it to specify an output folder for the renamed files.
Click "OK" to proceed.
Step 8 - Add Files for Renaming
Press “Add Files…” in the “Select Input Files” dialog to select files that need to be renamed. Consider also making backup copies of the input files before processing.
Select PDF files that need to be renamed and click "Open" once done. Note that files from multiple folders can be added with repeated use of the "Add Files..." button.
Selected PDF files will be listed in the "Select Input Files" dialog. Press "OK" once all necessary files have been selected.
Step 9 - Review and Confirm New Filenames
The software will process input files without renaming them yet, and present "computed" file names in the "Review and Confirm New Filenames" dialog. No files have been renamed at this step. Review the generated file names and edit them manually by double-clicking on an output filename cell.
Press “Rename” to confirm and start the renaming process.
Step 10 - Review the Processing Report
Check the renaming statistics. Click “OK” to open a processing report.
The processing report shows detailed information on how many files have been renamed or failed, along with input/output file names for each document.
Optionally save this report by pressing the "Save..." button. Click "Close" to close it.
Step 11 - Inspect the Results
Open the relevant folder location to check new filenames. The AutoSplit™ plug-in will have automatically renamed all input PDF files using the configured text search.
You can find more AutoSplit tutorials here.