• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating unique numerical representation of file path?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating unique numerical representation of file path?


  • Subject: Re: Creating unique numerical representation of file path?
  • From: Philip Aker <email@hidden>
  • Date: Sat, 13 Oct 2007 16:11:19 -0700

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


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Creating unique numerical representation of file path?
      • From: Andrei Tchijov <email@hidden>
References: 
 >Creating unique numerical representation of file path? (From: Richard Rönnbäck <email@hidden>)
 >Re: Creating unique numerical representation of file path? (From: deivy petrescu <email@hidden>)

  • Prev by Date: Re: Remote FileMaker Database Access
  • Next by Date: Re: Creating unique numerical representation of file path?
  • Previous by thread: Re: Creating unique numerical representation of file path?
  • Next by thread: Re: Creating unique numerical representation of file path?
  • Index(es):
    • Date
    • Thread