Script Sorting JPEGS into folders

Hello DT community!

I was wondering if I could get some help with developing a script. Preamble: I’m a historian and am indexing a folder from my external hard-drive with 1200 jpgs that I want to convert into a PDF so I can better annotate it on the iPad. When I try converting all 1200 into one PDF, it crashes my computer.

So, I was wondering if somebody could help me with a script that groups jpgs into folders of 25 each. Then the script would convert the jpgs in the folders into PDFs. Ideally, then the script could trash the jpgs in the folder, leaving just the merged PDF.

Does this sound easily scriptable?

Many many thanks for your help!

Here’s a simple example, just select the items that should be merged before executing it. As it doesn’t perform any error handling, the items aren’t trashed afterwards though.

property pMaxNum : 25

tell application id "DNtp"
	set theRecords to the selection
	set cnt to count of theRecords
	repeat with i from 1 to cnt by pMaxNum
		set n to (cnt - i + 1)
		if n > pMaxNum then set n to pMaxNum
		merge records (items i thru (i + n - 1) of theRecords) in current group
	end repeat
end tell

This is amazing!! It works like a charm and does exactly what I want it to. Thank you so much, I really appreciate it.

Chris, is there a script out there for “un-merge” Items?

I’m not aware of such a script.

1 Like