[sclug] Getting rid of duplicate files

Alex Butcher lug at assursys.co.uk
Thu Sep 28 13:31:12 UTC 2006


On Thu, 28 Sep 2006, Ed Davies wrote:

> Tim Sutton wrote:
>> ... Then I ran this little script to build md5 checksums:
>>
>>        1 PICFILE=/tmp/pictures$$.txt
>>        2 MD5FILE=/tmp/md5$$.txt
>>        3 find ~/Pictures/ -type f >> ${PICFILE}
>>        4 while read LINE
>>        5 do
>>        6   md5sum "${LINE}" >> ${MD5FILE}
>>        7 done < $PICFILE
>> ...
>
> I realise you're very unlikely to find an existing /tmp/md5$$.txt
> for the current process id but, just in case, I'd feel more comfortable
> deleting it first otherwise one could wind up thinking all the
> images are duplicates and deleting the lot, or something.

Even better, use something like:

PICFILE=`mktemp /tmp/pictures.XXXXXXXXXX`
MD5FILE=`mktemp /tmp/md5.XXXXXXXXXX`

[...]

rm -f $PICFILE $MD5FILE
exit 0

> Ed.

Best Regards,
Alex.
-- 
Alex Butcher, Bristol UK.                           PGP/GnuPG ID:0x5010dbff

"[T]he whole point about the reason why I think it is important we go for
identity cards and an identity database today is that identity fraud and
abuse is a major, major problem. Now the civil liberties aspect of it, look
it is a view, I don't personally think it matters very much."
  - Tony Blair, 6 June 2006 <http://www.number-10.gov.uk/output/Page9566.asp>


More information about the Sclug mailing list