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

**URL:** <https://discourse.devontechnologies.com/t/automation-to-send-original-document-to-trash-after-dt-converts-to-pdf-how/66783>\
**Category:** Automation\
**Created:** [September 21, 2021, 9:00pm UTC](https://discourse.devontechnologies.com/t/automation-to-send-original-document-to-trash-after-dt-converts-to-pdf-how/66783 "2021-09-21T21:00:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_N](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/r/13edae/32.png) [@Ryan\_N](https://discourse.devontechnologies.com/u/Ryan_N)\
**Post date:** [September 21, 2021, 9:00pm UTC](https://discourse.devontechnologies.com/t/automation-to-send-original-document-to-trash-after-dt-converts-to-pdf-how/66783/1 "2021-09-21T21:00:00Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [September 22, 2021, 1:40am UTC](https://discourse.devontechnologies.com/t/automation-to-send-original-document-to-trash-after-dt-converts-to-pdf-how/66783/2 "2021-09-22T01:40:41Z")

</div>

Here is a simple _teaching edition_ version that accomplishes what you’re asking…

```auto
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.

---

<div class="post-metadata">

**Author:** ![Ryan\_N](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/r/13edae/32.png) [@Ryan\_N](https://discourse.devontechnologies.com/u/Ryan_N)\
**Post date:** [September 22, 2021, 2:00pm UTC](https://discourse.devontechnologies.com/t/automation-to-send-original-document-to-trash-after-dt-converts-to-pdf-how/66783/3 "2021-09-22T14:00:38Z")

</div>

…and a _teaching edition_, it was! 😉

Works perfectly. Thanks for this, Jim!

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [September 22, 2021, 2:36pm UTC](https://discourse.devontechnologies.com/t/automation-to-send-original-document-to-trash-after-dt-converts-to-pdf-how/66783/4 "2021-09-22T14:36:44Z")

</div>

Glad to hear it and you’re very welcome!

See? Not all scripts have to be long and scary 😉
