My computer has Adobe Acrobat XI Standard.
I have over 5,000 files in a folder and I want to merge the files that have the same Prefix name in the filename. i.e.
The Results: The first 3 would get merged into 1 file
The next 2 would get merged into i file:
The last file would get copied or merged by itself -> 12009-23.pdf
and they would be in a destination folder other than the folder with the 5,000 .pdf files.
I found a code , but I don't know why its not working, i haven't scripted before, but I have run a macro or two..please help.
Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = "C:\test\"
Set oFolder = fso.GetFolder(sFolder)
bFirstDoc = True
If oFolder.Files.Count < 2 Then
MsgBox "You need to have at least two PDF files in the same folder to merge."
Call fso.CopyFile(oFolder.Files.Name, oFolder & "\Results")
Set AcroApp = CreateObject("AcroExch.App")
Set oMainDoc = CreateObject("AcroExch.PDDoc")
Set oTempDoc = CreateObject("AcroExch.PDDoc")
For Each oFile In oFolder.Files
If LCase(Left(oFile.Name, 8)) = ".pdf" Then
If bFirstDoc Then
bFirstDoc = False
oMainDoc.Open sFolder & "\" & oFiles.Name
oTempDoc.Open sFolder & "\" & oFiles.Name
oMainDoc.InsertPages oMainDoc.GetNumPages - 1, oTempDoc, 0, oTempDoc.GetNumPages, False
oMainDoc.Save 1,sFolder & "\Output.pdf"
MsgBox "Done! See Output.pdf file."
Set AcroExch.App = Nothing
Set oMainDoc = Nothing
Set oTempDoc = Nothing