Bryan Dunphy Bryan Dunphy - 4 years ago 220
AppleScript Question

Can Applescript or Python give me the Fully Qualified Path to a local file?

UPDATE: I guess what I really need to be able to do is to determine the Volume Name of the Boot Drive under Mac OS.

As an explanation of what I mean by "Fully Qualified", on Mac OS it would start with "/Volumes/" or on Windows with a drive letter (such as "C:\")

for example I want the Mac path "/Users/bryandunphy/Music" to become "/Volumes/'current default drive'/Users/bryandunphy/Music" or "'computer Name'/Volumes/'current default drive'/Users/bryandunphy/Music"

I need this to select a path supplied on the command line in a drop-down box that lists "'computer name'", "'each volume in /Volumes separately'", then you would select from the directories on the selected volume.

I already tried putting an Absolute Path in the "Filename" box but it ignored the path and just kept the name.

I have a photo of the initial drop-down box if anyone can suggest somewhere to upload it to so I could put a link to it in this question.

Answer Source

In AppleScript you can get the name of the startup volume with

set startupVolume to boot volume of (system info)

There are two different representations of paths in AppleScript:

  • HFS path, colon separated, starts always with a disk name:

    "Macintosh HD:Users:myself:Desktop:"
  • POSIX path, slash separated, starts always with a slash representing the startup volume:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download