• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Merge by Name

New Here ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

hello all,

I have scoured the internet trying to figure out how to quickly merge files with the same unique identifier. I have 5000 files and there files are named As follows:

5772000001_1

5772000001_2

5772000001_3

5772000002_1

5772000002_2

1. Is there a way to combined the files by unique identifier? Combined file 1 would have the three files from above that have this prefix (5772000001) and the two files that have the prefix (57720000012)

2. Is there a way to saved the combined files to a folder that has that same prefix?

Any help would be greatly appreciated.

TOPICS
Acrobat SDK and JavaScript

Views

447

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 19, 2018 Jan 19, 2018

Yes, if you know the name and location of the files you can write a short script to loop through the names and insert the files into a merged file.

Something like:

var oMergeDoc = new Doc();

for(...files...)

     oMergeDoc.insertPages(oMergeDoc.numPages-1, <Path to File>);

Votes

Translate

Translate
Community Expert ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

This is a tricky one.  If you knew the file names and folder ahead of time you could do this with an automation script.

But a more general solution would be to use a script in an Action.  An Action script is run each time a new file is loaded into the Action. The script doesn't know if it's the first or the last file so the first thing it needs to do is look for an already open merge file, if this file does not exist it creates a new one page PDF. If the merge PDF does exist, then it inserts the new file into the merge PDF.  As well as creating the Merge PDF, the script would also need to collect information from the user about the target file names. And there is an ordering issue. The files are not loaded into the Action in any predicable order. So if ordering is needed, there has to be some way to sort the files for inserting.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

Thom gave you an outline of how to do this within Acrobat. As you can see, it’s not straight forward. For cases like this, I prefer an approach that uses both Actobat to do the heavy PDF lifting and an application outside of Acrobat that handles the interaction with the user, reading of directories, and sorting filenames. You can e.g. program in VB or VBA (especially if you want to process information that comes from a spreadsheet) to do all file system operatione, and then use Acrobat’s IAC Interface to process the merging of PDF files.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

Karl and Thom, thank you so much for your guidance. Good place to start.

The interaction part is less of a worry. I thought there would be a script that would be able to handle the file merge for related names.

Thom, I have the file names and folder names. Is there a quicker approach per your first paragraph.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

Yes, if you know the name and location of the files you can write a short script to loop through the names and insert the files into a merged file.

Something like:

var oMergeDoc = new Doc();

for(...files...)

     oMergeDoc.insertPages(oMergeDoc.numPages-1, <Path to File>);

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2018 Jan 24, 2018

Copy link to clipboard

Copied

LATEST

Thank you, Thom! I appreciate your help a great deal!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines