Opening and Saving PDFs

I am new to AppleScript. I am trying to create a Script that will open PDF’s in Acrobat and then Resave them to a different location. I copied bits and pieces from other scripts to try and make this work. So far I have the script opening a dialog box which prompts the user to select a folder. When the user selects the folder the script then selects the PDF that is in that folder and opens it. I would actually like to have the script work so that it doesn’t require the user to select a folder but just runs the script on what is in that folder. Once the file has been opened I would like to save it to a different location and then delete the orginal file from the source folder. Here is what I have so far.


tell application "Finder"
	set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
	tell application "System Events"
		set these_files to every file of folder this_folder
	end tell
	repeat with i from 1 to the count of these_files
		set this_file to (item i of these_files as alias)
		set this_info to info for this_file
		if visible of this_info is true and alias of this_info is false then
			tell application "Finder"
				activate
				make new Finder window to folder "BMO Save" of folder "Desktop" of folder "rgreenidge" of folder "Users" of startup disk
				open document file "FM.pdf" of folder "In" of folder "BMO Save" of folder "Desktop" of folder "rgreenidge" of folder "Users" of startup disk
				
			end tell
			
		end if
	end repeat
end tell

Any help would be appreciated.
Thanks,
Richard.

Model: G5
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Have you looked at this thread? Same sort of problem.

Hi, Richard.

It’s not clear from your post whether or not you actually want to do anything with the file in Acrobat before resaving it. If you just want to move it from one location to another, you can simply get the Finder to move it there (as in the thread referenced by Adam).

I presume that your source folder will always be “BMO Save” on your desktop. The Finder has its own keyword for the current user’s “Desktop” folder, so you could shorten folder “BMO Save” of folder “Desktop” of folder “rgreenidge” of folder “Users” of startup disk to folder “BMO Save” of desktop. (In fact, if you don’t specify where an item is, the Finder assumes it’s on the desktop, so you could just write folder “BMO Save”. But it’s probably clearer to add of desktop as well.) There’s no need to open any folders before making the move, though of course they must both exist.

tell application "Finder"
	set destinationFolder to folder "Blah" of folder "Blah" of disk "Blah" -- Your destination here.
	tell (every file of folder "BMO Save" of desktop whose name extension is "pdf" and class is not alias file)
		move to destinationFolder
		delete -- In case the destination folder's on another volume.
	end tell
end tell

You may need to make provision for there already being a file with the same name in the destination folder.

Thanks, Nigel for the reply. We are working with PDF files from our client that are not ripping properly on the Front End for our printer. Until we
can figure out what the problem is with these PDF’s, we have found that by resaving them in Acrobat solves the problem. We would like to
try and automate the process of opening the PDF’s and having them saved to a new destination. If possible I would like to try and remove the files that have already been resaved from the “In” folder so that they do not get re-processed.

Thanks,
Richard.

Thanks Adam for your reply I will give that part of the script a try.

Thanks,
Richard.