I have a cron job which runs a script to unrar all files in a certain directory (/rared for argument's sake) and place the expanded files in /unrared. I would like to change this script so that it deletes the original rar archives from /rared only if they successfully extracted.
This does not mean that unrar has reported that they have been fully extracted, because I have had data corruption during decompression before.
Ideally (pie-in-the-sky, just to give you an idea of what I'm shooting for,) the unrar program would include this functionality, comparing an expected md5sum value with the actual md5sum value and only deleting the archive if they match. I don't mind scripting this entire process if I have to, but there must be a better way than unraring twice and comparing md5sums.
A friend of mine has been working on a bash shell script to do this which is on github here.
https://github.com/arfoll/unrarall
This is the script I have so far, it first checks if there is a current
unrar
operation running, and exits if there is (don't want to swamp the disk with heaps of read/writes). It then unRARs all files in /rared which have not already been unRARed, placing extracted files in /unrared. It does not yet check the extracted files or delete the archives:This is the crontab entry which accompanies it: