I create pdfs for clients, compress them to zip files and then email them. This means that I have an original larger pdf and then a zip file. I don’t need both so I would like to automatically delete the original file after compressing.
Here’s a very similar script I use to compress pdf files occasionally:
set tFile to (choose file of type {"PDF"}) as text
set source to quoted form of POSIX path of tFile
set dest to quoted form of POSIX path of (tFile & ".zip")
do shell script "ditto -ck " & source & space & dest
do shell script "rm " & source
Note that the PDF will not appear in the trash – rm simply removes it.
When you execute the line below, a preference pane for the built in archieve utility will be revealed, there are options there, to move the archieved files to trash after archieving.
There is also an option to set archieve format to zip there, which you must choose.
When you have set those options, then you won’t need a script at all, every file you choose to archieve the normal way, by rightclicking and choosing compress, will get its original moved to trash.
do shell script "open " & "/System/Library/CoreServices/Archive\\ Utility.app/Contents/Resources/Archives.prefPane/"