Automation to send original document to trash after DT converts to PDF (how?)

If I select, say, 10 documents, then right click and choose Convert > to Paginated PDF, I would like the initially-selected (non-PDF) documents to go to trash after the PDFs of same are produced.

Is a script necessary to pull this off, or am I perhaps missing the obvious ; )

Thanks all!

Here is a simple teaching edition version that accomplishes what you’re asking…

tell application id "DNtp"
	repeat with thisFile in (selected records)
		set recDB to (database of thisFile) -- In case you're acting on smart groups or search results
		set recKind to (kind of thisFile as string) -- A localized value but this is safe since it's just used for the error message, if needed
		set newRecord to convert record thisFile to PDF document -- Convert the file to a paginated PDF in place
		if (newrecord ≠ missing value) then -- Check to see if the record was made
			move record thisFile to trash group of recDB -- If so, move the original to the Trash
		else
			display alert "Can't convert " & recKind & " files into PDFs." -- Warn and continue…
		end if
	end repeat
end tell

This code would be usable on a selection in a group or a smart group - global or local.

1 Like

…and a teaching edition, it was! :wink:

Works perfectly. Thanks for this, Jim!

Glad to hear it and you’re very welcome!

See? Not all scripts have to be long and scary :wink:

1 Like