Batch Place PDF

I’m trying to batch place PDFs into an Indesign doc from a folder of PDF’s then export it out as a PDF again. (I know sounds weird, but it does have a purpose).

This is what I got so far, but can’t seem to get the PDF to place into the Indesign Doc.

tell application "Finder"
	
	set myFolder to (choose folder with prompt "Select the folder containing the PDFs you want to convert")
	set myFiles to count every item of folder myFolder
	set PDF_List to every item of folder myFolder as alias list
	
	set folder_path to (choose folder with prompt "Select folder to Save PDF files") as string
	
	
	
	tell application "Adobe InDesign CS3"
		repeat with i from 1 to myFiles
			activate
			set page number of PDF place preferences to 2
			set FormDoc to make document
			tell document preferences of FormDoc
				set {page height, page width} to {"12 in", "10"}
			end tell
			tell FormDoc
				try
					set LayerName to layer "Image layer" of FormDoc
				on error
					set LayerName to make layer with properties {visible:true, locked:false, name:"PDF"}
					delete layer 2
				end try
				delete color "C=100 M=0 Y=0 K=0"
				delete color "C=0 M=0 Y=100 K=0"
				delete color "C=0 M=100 Y=0 K=0"
				delete color "C=15 M=100 Y=100 K=0"
				delete color "C=75 M=5 Y=100 K=0"
				delete color "C=100 M=90 Y=10 K=0"
				
				tell FormDoc
					set pdf_page to place myFiles on page 1
					move pdf_page to {"-.5", "-.5"}
					
					set PDF_name to folder_path & myFiles & "_ WEB" & ".pdf"
					
					tell FormDoc
						export format PDF type to PDF_name using "LUXE Web PDF" without showing options
						
						close FormDoc saving no
					end tell
				end tell
			end tell
		end repeat
	end tell
	
end tell

Thanks
Tim

I haven’t tested the code, but I see that you assigned myfiles to be a number (on line 3). You can’t place that.

Hi,

as Marc commented, you’re placing the index variable, not the file


.
tell FormDoc
	set pdf_page to place (item i of PDF_List) on page 1
	set newName to text 1 thru -5 of name of (info for item i of PDF_List)
	move pdf_page to {"-.5", "-.5"}
	set PDF_name to folder_path & newName & "_ WEB" & ".pdf"
	tell FormDoc
		export format PDF type to PDF_name using "LUXE Web PDF" without showing options
		close FormDoc saving no
	end tell
end tell
.

In my (german) version of ID this line generates an error

set {page height, page width} to {"12 in", "10"}

this works

set {page height, page width} to {"12i", "10i"}

Thanks That worked Great
Now I just have to figure out how to align the picture box center to the pasteboard.