8 Replies Latest reply on Sep 7, 2010 8:09 PM by brettpolo

    How to reference Macintosh HD in file path

    Barqx

      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.

        • 1. Re: How to reference Macintosh HD in file path
          Muppet Mark-QAl63s Level 4

          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…

          • 2. Re: How to reference Macintosh HD in file path
            [Jongware] Most Valuable Participant

            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?

            1 person found this helpful
            • 3. Re: How to reference Macintosh HD in file path
              [Jongware] Most Valuable Participant

              .. 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 )

              1 person found this helpful
              • 4. Re: How to reference Macintosh HD in file path
                brettpolo Level 1

                Well, internaly, the OS would be fine.  The folder would be located at /USB DISK, and the usb stick would

                be mounted at /Volumes/USB DISK.  If you then plugged in a second usb stick witht the same name, it would be at /Volumes/

                USB DISK-1.

                 

                That said, i'm not sure how InDesign would deal with with that situation, but presumably, whatever part of the JavaScript engine translates URI address to OS paths would take care of it.  When I get to work tomorrow, i'll test this out.

                • 5. Re: How to reference Macintosh HD in file path
                  Muppet Mark-QAl63s Level 4

                  Jong, I tried that script on a mac with a single partitioned drive (one side as boot) with about a half dozen external drives/servers mounted. Every other drives mount point should be in '/Volumes/' as suggested… Im at home now on my little iMac this is what I see if I put USB's of the same name in… then go check in terminal…

                   

                  Unknown-00-23-12-22-cb-79:~ marklarsen$ diskutil list

                  /dev/disk0

                     #:                       TYPE NAME                    SIZE       IDENTIFIER

                     0:      GUID_partition_scheme                        *931.5 Gi   disk0

                     1:                        EFI                         200.0 Mi   disk0s1

                     2:                  Apple_HFS Macintosh HD            931.2 Gi   disk0s2

                  /dev/disk1

                     #:                       TYPE NAME                    SIZE       IDENTIFIER

                     0:      GUID_partition_scheme                        *931.5 Gi   disk1

                     1:                        EFI                         200.0 Mi   disk1s1

                     2:                  Apple_HFS Time Machine Backups    931.2 Gi   disk1s2

                  /dev/disk3

                     #:                       TYPE NAME                    SIZE       IDENTIFIER

                     0:     FDisk_partition_scheme                        *471.0 Mi   disk3

                     1:                 DOS_FAT_16 JONG                    470.7 Mi   disk3s1

                  /dev/disk4

                     #:                       TYPE NAME                    SIZE       IDENTIFIER

                     0:     FDisk_partition_scheme                        *471.0 Mi   disk4

                     1:                 DOS_FAT_16 JONG                    470.7 Mi   disk4s1

                  /dev/disk5

                     #:                       TYPE NAME                    SIZE       IDENTIFIER

                     0:     FDisk_partition_scheme                        *471.0 Mi   disk5

                     1:                 DOS_FAT_16 JONG                    470.7 Mi   disk5s1

                   

                   

                  Here is the pic…

                  Picture 1.png

                  • 6. Re: How to reference Macintosh HD in file path
                    [Jongware] Most Valuable Participant

                    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!"

                    • 7. Re: How to reference Macintosh HD in file path
                      Muppet Mark-QAl63s Level 4

                      I did go back and rename those drives with unique names straight after its not the kind of thing advocate…

                      • 8. Re: How to reference Macintosh HD in file path
                        brettpolo Level 1

                        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.