I want Automator script to remove files from Trash without user input. AppleScript
empty the trash
only works on unstuck files. Similar commands work in Terminal to remove files.
sudo rm -rf ~/.Trash
Still, copies of 'stuck' files are left in Trash. For example, files get stuck during move to Trash, leaving files halfway to Trash but stuck in between, so zero-byte files stuck in Trash... Terminal command will unlink Trash contents so that Trash will empty, including the zero-bytes junk.
sudo rm -rf ~/.Trash /Volumes/*/.Trashes
But Terminal has to be opened separately, then requires a user password and then manual drag and drop, blocking automation... How to automate everything?
Here's what we generally do now and need to replace with script:
- Check if any files in Trash
- If files in trash, then empty
- Check if any files in trash
- If files still in Trash, then open Terminal
- Run Terminal command sudo rm -rf -i -dPRrvW to break file permissions blocking delete
- Enter password to allow permissions change
- drag and drop stuck Trash files onto Terminal window
- Delete Trash files
- Check if any files in Trash
- If no file in Trash, then end script run