Skip to main content
Known Participant
September 7, 2010
Answered

How to reference Macintosh HD in file path

  • September 7, 2010
  • 1 reply
  • 7441 views

How do I reference the Macintosh HD in a file path, in case it is renamed?

I tried:

myFile = File ('Macintosh HD/myTxt.txt');

But nothing happens, when I write to the file.

This topic has been closed for replies.
Correct answer brettpolo

Okay, I got it. The system disk is always /, other disks appear in /Volumes, removables get named on mounting.

I Learned Something Today™: disk ops on a Mac are far less a hassle than they were on my ol' Windows machine!

As in "Wait: I got my iPod plugged in, and that's got a J: assigned, so .. this USB stick I plug in next to the one that was already there should be "K:", right?" Windows: "Nah, I tell you it's G: and throw out one of the removable hard disks. Ha ha ha!"


It's the UNIX filesystem, and it is much easier (for me at least) then winodws.  As a quick side note, root is always /, but it also is alised in "/Volumes/Macintosh HD/", or whatever your main HD name is.  As Mark said, it's realy a bad idea to have more then one volume with the same name, as the internal FS mappings may not mirror the way that InDesign resolves the URI. 

1 reply

Muppet_Mark-QAl63s
Inspiring
September 7, 2010

I think the answer to that is you don't…

var w = new File('/Untitled.txt'); if (w.exists){      w.open('r');      var x = w.read();      w.close();      $.writeln(x); }else{      $.writeln('false'); }

Your file is sat at the system's mount point. This worked just fine for me…

Jongware
Community Expert
Community Expert
September 7, 2010

Muppet, you only have one single hard drive, right? I'm on a Mac right now, and if I insert a USB stick, it gets mounted alongside my HD ... Oh wait, I might as well try it. Hold on.

alert (app.activeDocument.fullPath);

for a file on my HD shows (ehm. an error.). Let's try

alert (app.activeDocument.fullName);

shows

/Untitled-1.indd

And when saved on the USB stick, it's

/USB%20DISK/Untitled-1.indd

... Now that was unexpected ... Okay, what does happen if you have two hard drives?

Jongware
Community Expert
Community Expert
September 7, 2010

.. or, for that matter, what if I first create a new folder "USB DISK" in the root of my HD and then insert the USB disk with the same name...? (No, I'm not going to try that. Not before someone tells me what should happen )