As I started inventorying my gadgets, looking at all of the serial number barcodes gave me some ideas on how to improve my scanning process. I made a series of revisions to my AppleScript to let it handle serial numbers whenever possible.

Unfortunately, Delicious Library doesn’t provide any mechanism that I can find that lets a script know that a lookup has been ignored. If it did, things would have been simple; we could just assume that ignored lookups aren’t valid product codes, so they’re likely to be serial numbers. Instead, I ended up making a number of tests on the scan data to try to figure out if it is a serial number or product code:

  1. Check to see if it starts with the letter “S”. Nicer vendors prefix their serial number barcodes in this way to make automated scanning easier.
  2. Check the length of the code; UPCs, EANs, and ISBNs are generally 10, 12, or 13 numbers long. Anything that doesn’t match is probably a serial number.
  3. Finally, we can check to see if the scanned code is all numeric or not; if it’s not, let’s make it a serial number.

These checks aren’t 100% fool-proof. In an ideal world, I would pass the code through the checksum algorithms used by the various code standards to see if it is a valid product code or not. For my purposes, though, they seem to be accurate enough. I also made one small but helpful change; the script now launches Delicious Library if it’s not already running.

You can grab an updated copy of the Delicious Barcode Scanner script, and inventory ‘till your trigger finger is sore.