On Oct 13, 2007, at 1:33, Richard Rönnbäck wrote:
So, how can I turn something like this:
/Some/Very/Long/POSIX/Path/
into a shorter number like this
1234
And be absolutely sure that no other path/sequence of characters could get the same number?
It's not a number, but you can set up an association pair of a path to a uuid. uuids are always 36 characters long.
set lib to POSIX path of (path to library folder from user domain)
set pic to POSIX path of (path to pictures folder)
set uuid to {lib, (do shell script "uuidgen"), pic, (do shell script "uuidgen")}
Because uuids are unique (you can't get uuidgen to produce the same one), you'll need to store the mapping pairs externally right after they are first obtained. You can use the shell tool 'defaults' with an invented identifier (com.ronnback.filemaps e.g.) for this purpose. Store them with the key set to the file path and the value set to the uuid.
This kind of technique is used extensively at Apple for all sorts of things. For example, Mail.app signatures are stored and retrieved by via a mapping.
Philip Aker
email@hidden