Running AutoSplit from a Command-Line BAT File

AutoSplit Pro plug-in for Adobe® Acrobat®

Introduction
It is possible to run AutoSplit Professional operations from outside of Adobe Acrobat via a command-line BAT file. Use this method to automate document processing by starting the processing from an another application or Windows Task Scheduler. This functionality is available in version 5.6 and up.
You would need to configure the particular AutoSplit operation using a regular method via user interface prior to running it via a BAT file.
Configure AutoSplit Operation
IMPORTANT: Make sure you are using AutoSplit Pro plug-in. This functionality is not available in AutoSplit Standard.
Use plug-in's menu(s) to configure a particular AutoSplit operation. Here is the list of the operations that are supported for the BAT file execution:
  1. Split Document
  2. Auto-Rename PDF Files
  3. Merge Multiple Documents Using Control File
  4. Merge Documents into Single Document
  5. Merge Documents from Multiple Folders
  6. Merge Documents with Similar Filenames
  7. Delete Pages by Text Search
  8. Find Duplicate Pages
Save Processing Settings
Each of the above mentioned operations provides a way to save processing parameters as a settings file. For example, for "Split Document" use "Save Profile" button to save settings as *.apr file. All other operations have a set of "Save Settings..." and "Load Settings..." (or just "Save"/"Load") buttons for saving settings into a file.
Here is a list of settings file extensions for each operation:
  1. Split Document: *.apr
  2. Auto-Rename PDF Files: *.docren
  3. Merge Multiple Documents Using Control File: *.mergefile
  4. Merge Documents into Single Document: *.ams
  5. Merge Documents from Multiple Folders: *.mfmf
  6. Merge Documents with Similar Filenames: *.mfmf
  7. Delete Pages by Text Search: *.textsearch
  8. Find Duplicate Pages: *.duppages
Creating BAT Files
Use any plain text editor (such as Notepad) to create a blank text file. Add the following lines to the file. Make sure to replace paths and filenames with the actual filenames you are using.
The example below shows how to start Acrobat DC and split Test.pdf PDF file using the document splitting settings from SplitProfile.apr file.
SET AUTOSPLIT_INPUT_FILE=C:\Data\Test.pdf
SET AUTOSPLIT_CONFIG_FILE=C:\Data\SplitProfile.apr
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=Split
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
The environment variable AUTOSPLIT_INPUT_FILE is used to specify a full file path to the PDF file that needs to be used for the job while AUTOSPLIT_CONFIG_FILE specifies a full file path to the settings file.
The environment variable AUTOSPLIT_MODE is used to specify a processing operation. Here is the list of the supported values:
  • Split - Split Document
  • RenameFile - Auto-Rename PDF Files
  • MergeControlFile - Merge Multiple Documents Using Control File
  • Merge - Merge Documents into Single Document
  • MergeFolders - Merge Documents from Multiple Folders
  • MergeSimilar - Merge Documents with Similar Filenames
  • DeletePages - Delete Pages by Text Search
  • ExtractPages - Extract Pages by Text Search
  • FindDuplicatePages - Find Duplicate Pages
Passing Input Filename to BAT Files
You can pass a file path to the BAT file to make it run on a specific input file. Make a small modification to the BAT file to allow using parameters. When you call a batch file, you can enter data after the command that the batch file refers to as %1, %2, etc. For example, the following command assigns the first parameter passed to the BAT file to AUTOSPLIT_INPUT_FILE variable.
SET AUTOSPLIT_INPUT_FILE=%1
SET AUTOSPLIT_CONFIG_FILE=C:\Data\SplitProfile.apr
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=Split
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Now pass the file path to a PDF file when executing a BAT file:
AutoSplit.BAT "c:\data\myfiles\document.pdf"
Creating Log Files
Use AUTOSPLIT_LOG_FILE variable to specify a log file location. If a log file does not exist, it will be automatically created. If a log file already exists, then new records will be appended to the file. Log files can be used for troubleshooting and record keeping.
SET AUTOSPLIT_LOG_FILE=C:\Data\AutoSplitLog.txt
Processing Whole Folder
Only two commands (Split and RenameFile) take input file as a parameter. Alternatively, it is possible to specify a folder instead of an individual PDF file. All PDF files from the folder will be processed one by one. Use AUTOSPLIT_INPUT_FOLDER variable to specify a full path to the processing folder.
SET AUTOSPLIT_INPUT_FOLDER=C:\Data
Example for "Auto-Rename PDF Files" operation
This is an example of running "Auto-Rename PDF Files" operation on a specific file Test.pdf located in C:\Data folder:
SET AUTOSPLIT_INPUT_FILE=C:\Data\Test.pdf
SET AUTOSPLIT_CONFIG_FILE=C:\Data\RenameTest.docren
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=RenameFile
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
This is an example of running "Auto-Rename PDF Files" operation on all PDF files located in C:\Data folder:
SET AUTOSPLIT_INPUT_FOLDER=C:\Data
SET AUTOSPLIT_CONFIG_FILE=C:\Data\RenameTest.docren
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=RenameFile
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Example for "Merge Multiple Documents Using Control File" operation
Note that all "merge" operations do not use AUTOSPLIT_INPUT_FILE variable, because the input files for the merge are specified as part of the settings. There are typically more than one input file involved. You can use the example below for all 3 merge operations.
SET AUTOSPLIT_CONFIG_FILE=C:\Data\Settings.mergefile
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=MergeControlFile
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Example for "Merge Documents From Multiple Folders" operation
Note that all "merge" operations do not use AUTOSPLIT_INPUT_FILE variable, because the input files for the merge are specified as part of the settings. There are typically more than one input file involved.
SET AUTOSPLIT_CONFIG_FILE=C:\Data\Settings.mergefile
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=MergeFolders
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Example for "Merge Documents with Similar Filenames" operation
Note that all "merge" operations do not use AUTOSPLIT_INPUT_FILE variable, because the input files for the merge are specified as part of the settings. There are typically more than one input file involved.
SET AUTOSPLIT_CONFIG_FILE=C:\Data\Settings.mergefile
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=MergeSimilar
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Example for "Merge Documents into Single Document" operation
Note that all "merge" operations do not use AUTOSPLIT_INPUT_FILE variable, because the input files for the merge are specified as part of the settings. There are typically more than one input file involved.
SET AUTOSPLIT_CONFIG_FILE=C:\Data\Settings.mergefile
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=Merge
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Example for "Delete Pages by Text Search" operation
Note that DeletePages operation needs to have an output folder specified where to save the modified files. This operation does not overwrite the input file(s) and always saves output documents under a different filename and/or folder location. This means that BAT file needs to specify three file paths: a settings file, an input PDF file or a folder, and an output folder.
SET AUTOSPLIT_CONFIG_FILE=C:\Data\Settings.textsearch
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=DeletePages
SET AUTOSPLIT_INPUT_FILE=C:\Data\Input\InputDocument.pdf
SET AUTOSPLIT_OUTPUT_FOLDER=C:\Data\Output
SET AUTOSPLIT_LOG_FILE=C:\Data\DeletedPagesLog.txt
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Example for "Exract Pages by Text Search" operation
Note that ExtractPages operation needs to have an output folder specified where to save the modified files. Please note that this operation can modify input files if an option to delete extracted pages is enabled in the settings. Please see the full tutorial for Extract Pages by Text Search operation.
SET AUTOSPLIT_CONFIG_FILE=C:\Data\Settings.textsearch
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=ExtractPages
SET AUTOSPLIT_INPUT_FILE=C:\Data\Input\InputDocument.pdf
SET AUTOSPLIT_OUTPUT_FOLDER=C:\Data\Output
SET AUTOSPLIT_LOG_FILE=C:\Data\ExtractPagesLog.txt
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Example for "Find Duplicate Pages" operation
This operation searches PDF file for duplicate pages and creates a report in HTML format. It does not modify input PDF document.
Note that output folder for this operation is specified in the settings file (*.duppages). You can configure and save settings in the regular application dialog via "Plug-ins > Split Documents > Find and Delete Duplicate Pages" menu.
SET AUTOSPLIT_CONFIG_FILE=C:\Data\Settings.duppages
SET AUTOSPLIT_BAT_ENABLE=ON
SET AUTOSPLIT_MODE=FindDuplicatePages
SET AUTOSPLIT_INPUT_FILE=C:\Data\Input\InputDocument.pdf
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
64-bit vs 32-bit Adobe Acrobat
Note that default path to Adobe Acrobat installation is different depending on the version of Adobe Acrobat used. Make sure to use the correct path in the BAT files when starting Acrobat.
64-bit Acrobat path: C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe
32-bit Acrobat path: C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Acrobat.exe
Save a BAT File
Save the BAT file with *.bat file extension. Make sure to select a proper file filter in the "Save As" dialog in Notepad to avoid saving the file with a default *.txt file extension.
Run a BAT File
The mail merge job can be executed by double-clicking on the BAT file in Windows File Explorer window or by running it from another application.
Please note that the BAT file will open Adobe Acrobat and may display a progress bar during the processing. Use /h switch on the Acrobat's command line to optionally run Adobe Acrobat minimized:
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
Starting AutoSplit from a C# Application
Here is a sample C# code that shows how to launch AutoSplit from a .NET application and pass all necessary parameters via the environmental variables.
System.Diagnostics.Process firstProc = new System.Diagnostics.Process();
firstProc.StartInfo.FileName = @"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe";
firstProc.EnableRaisingEvents = true;
firstProc.StartInfo.UseShellExecute = false;
firstProc.StartInfo.Arguments = @"/n /h"; // pass command-line parameters
firstProc.StartInfo.EnvironmentVariables.Add("AUTOSPLIT_INPUT_FILE", @"C:\Data\Test.pdf");
firstProc.StartInfo.EnvironmentVariables.Add("AUTOSPLIT_CONFIG_FILE", @"C:\Data\Settings.apr");
firstProc.StartInfo.EnvironmentVariables.Add("AUTOSPLIT_BAT_ENABLE", @"ON");
firstProc.StartInfo.EnvironmentVariables.Add("AUTOSPLIT_MODE", @"Split");
firstProc.Start();
Click here for a list of all step-by-step tutorials available.