clean up sensitive (Mac) Preview files
It’s handy to print things to Preview - maybe you want to save the “security” questions and (random) answers from a new site registration, to a secure place (like 1Password) and now you’re wondering where that temporary file is - with that sensitive info.
So; fire up a terminal:
find $TMPDIR -type f -mmin -1440 -iname \*.pdf\* -print0 | xargs -0 -L1 -t -I% mv -i % ~/.Trash/; open ~/.Trash/
Notes:
- start findwith these options / arguments:- in $TMPDIR- your own user’s dir for temporary files- (which will automatically get cleaned up - eventually)
 
- -type f- we want to find files only
- -mmin -1440- files modified in the last 1440 minutes (1 day); tweak as you like
- -iname \*.pdf\*- files of with an extension of- pdf*
- -print0- output results null-terminated (to handle “special” chars)
 
- in 
- |- pipe results to- xargs, to process them using these options:- -0- handle null-terminated input
- -L1- process one item at a time (if any)
- -t- show commands as they’re executed
- -I%- in the ensuing command, replace- %there, with the resulting filename/s
 
- mv- move these files, with the following options:- -i- interactive prompt (instead of overwrite)
- %- the source filename, substituted by xargs
- ~/.Trash/- destination dir; put them here
 
- open ~/.Trash/- open (in Finder), for your review