Jan 22

Generate a unique ID for your image scans, with Data::Uniqid

Category: Linux,Perl   — Published by tengo on January 22, 2012 at 9:46 am

When I scan images, or paper notes, I like to leave a short note on the document I scanned referrring to my scanned digital copy of it. For example, when I scanned an image, I note on the back of it that this one is already scanned and I don't have to rescan it over and over in case I forget about my previous scan.

But how can I easily find the digital equivalent on my cluttered hard drive? One easy approach is to insert a unique string into the name of the file, which is searchable across probably millions of files. And, you can do this with a simple Perl one-liner:

perl -e "use Data::Uniqid; print Data::Uniqid::suniqid.\"\n\";"

The suniqid() is quite short and random enough (vs. uniqid) and mostly easy to read once on paper even in bad handwriting. If you then name your file, for example, My_funny_valentine_moment_suniqid<insert suniqid here>.jpg you can be sure that you can later on track it down wherever on your disk it may hide.