Jump to content

abenitez77

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by abenitez77

  1. That sounds like a good plan. I haven't written vbscripts in a while so i have to recall syntax. thanks.
  2. I have this code that I got from "igor krupitsky which he posted on another site. It merges (appends) 2 pdf files. I need to edit the code so that it does this:I have 8,000 files in a folder and I want to merge the files that have the same prefix name in the filename. i.e.122TX4939.pdf122TX4939 Support.pdf122TX4939 Additional.pdf333RS111.pdf333RS111 Support.pdf555DA77.pdfResults:The first 3 would get merged into 1 file:122TX4939.pdfThe next 2 would get merged into 1 file:333RS111.pdfThe last file would get copied or merged byitself555DA77.pdfand they would be in a destination folder other than the folder with the 8,000 pdf files.Code:Set fso = CreateObject("Scripting.FileSystemObject")sFolder = fso.GetParentFolderName(WScript.ScriptFullName)Set oFolder = fso.GetFolder(sFolder)Set oArgs = WScript.ArgumentsIf oArgs.Count = 0 Then'Double ClickMergeFilesElse'Drag & DropFor I = 0 to oArgs.Count - 1If LCase(Right(oArgs(I), 4)) = ".pdf" ThenMergeTwoFiles oArgs(I)End IfNextEnd If'=======================================================Sub MergeFiles()bFirstDoc = TrueIf oFolder.Files.Count < 2 ThenMsgBox "You need to have at least two PDF files in the same folder to merge."'fso.CopyFile(oFolder.Files.Name, oFolder & "Results")Exit SubEnd IfFor Each oFile In oFolder.FilesIf LCase(Right(oFile.Name, 4)) = ".pdf" ThenIf bFirstDoc ThenbFirstDoc = FalseSet oMainDoc = CreateObject("AcroExch.PDDoc")oMainDoc.Open sFolder & "" & oFile.NameElseSet oTempDoc = CreateObject("AcroExch.PDDoc")oTempDoc.Open sFolder & "" & oFile.NameoMainDoc.InsertPages oMainDoc.GetNumPages - 1, oTempDoc, 0, oTempDoc.GetNumPages, FalseoTempDoc.CloseEnd IfEnd IfNextoMainDoc.Save 1, sFolder & "Output.pdf"oMainDoc.CloseMsgBox "Done! See Output.pdf file."End Sub'=======================================================Sub MergeTwoFiles(sFileName)If Not fso.FileExists(sFolder & "Output.pdf") Thenfso.CopyFile sFileName, sFolder & "Output.pdf"Exit SubEnd IfSet oMainDoc = CreateObject("AcroExch.PDDoc")oMainDoc.Open sFolder & "Output.pdf"Set oTempDoc = CreateObject("AcroExch.PDDoc")oTempDoc.Open sFileNameoMainDoc.InsertPages oMainDoc.GetNumPages - 1, oTempDoc, 0, oTempDoc.GetNumPages, FalseoMainDoc.Save 1, sFolder & "Output.pdf"oTempDoc.CloseoMainDoc.CloseMsgBox "Done! See Output.pdf file."End Sub
×
×
  • Create New...