Re: Extracting the name of a CD for an archiving macro

Posted by Pariksheet Nanda on
URL: http://imagej.273.s1.nabble.com/Extracting-the-name-of-a-CD-for-an-archiving-macro-tp5004769p5004860.html

On Thu, Sep 12, 2013 at 4:07 PM, Gareth Howell <[hidden email]> wrote:
> The problem I have is getting the
> CD name from the CD. Using getDirectory I can map to the drive (e.g. E:
>

Since you're using Windows and mention E: drive as your CD drive, use:

    exec("cmd /C vol E:");

The ImageJ log window will show the string result.  To process the
returned string for the label you could do something like this:

    cd_drive = "E"
    // Run Windows' `vol` command.
    vol = exec("cmd /C vol " + cd_drive + ":");
    // Check if it has a label.
    label = "none"
    if (indexOf(vol, " has no label.") == -1)
    {
        start = indexOf(vol, " is ") + lengthOf(" is ");
        end = indexOf(vol, "\n");
        label = substring(vol, start, end);
    }
    print(cd_drive + ": Label = " + label);


> Gareth

Pariksheet

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html