I need to create multiple multi-page pdf files by combining all the
files with the same initial file name string. I was able to do this
but the process is also creating some duplicate files with only the
first required pdf. I either need a way to stop the scripts from
creating the duplicates or a script to delete the duplicate files
which are smaller in size.

Code is below.

The output is

['A11', 'A139_1-A136_1', 'A13h-MH1', 'A1_1-B1_0', 'A20_11-12',
'A20_11-12 ', 'A20_12-13', 'A20_9-10', 'A20_9-10 ', 'A22_15-A32_1',
'A22_15-A32_1 ',...

you would note that the result includes the 'duplicate', 'A20_9-10',
'A20_9-10 '. It is not really duplicate as the latter contains an
extra space.

Also they are different size

A20_9-10 __IC8.pdf 4551017 A20_9-10 __IC8.pdf 4551017
A20_9-10__IC7.pdf 6378185

So I want to retain the __IC7 (as it is the largest) and delete the
others or have my script not create the 'duplicates' in the first
place.

CODE for Creating multipage PDF's

# Script to create multipagePDF from  # import modules, specify a
directory path  import os, glob, arcpy path = os.getcwd()  fileList =
glob.glob('*.pdf') x=0 List = [] oName = 'null' Name = 'null' # loop
through the list of files   for file in fileList:     positionDot =
file.find('(')     #print positionDot     if positionDot == -1:
positionDot = file.find('--')     if positionDot == -1:
positionDot = file.find('.')     fileNo = positionDot # position of
the character to extract     #print fileNo     #fileType =
file[fileNo:positionDot] # character string to extract from xth
character to yth character     oName=Name     Name = file[0:fileNo] #
Character string to retain from xth character to yth character
#print file,fileNo,fileType, Name     #print oName, Name     if oName !
= Name:         List.append(Name)     L=List no_dups = list(set(L));
no_dups.sort() print no_dups FileCount = len(no_dups)  while
x<FileCount:     Name=no_dups[x]     pdfStore=glob.glob(Name
+"*.pdf")      for file2 in pdfStore:        print pdfStore,
Name        outPDFpath = path+"\\out\\"+Name+"__IC"+str(x)+".pdf"
x=x+1 #Create a new PDF object to store the results     outputPDF =
arcpy.mapping.PDFDocumentCreate(outPDFpath)   #Loop through and append
each PDF in the list     for eachPDF in pdfStore:
outputPDF.appendPages(str(eachPDF))  print "Created: " + outPDFpath
#Save the changes and open the result automatically    print
outPDFpath outputPDF.saveAndClose() #os.startfile(outPDFpath)  #Remove
variable reference to file del outputPDF I have started a script to
delete all but the

Reply via email to