Extracting the name of a CD for an archiving macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Extracting the name of a CD for an archiving macro

Gareth Howell
H, I'm looking for a bit of help on a small cataloging macro I'm writing. We have thousands of images spread across loads of CDs and external drives which make them very hard to search for data. I am trying to write a macro to undertake the archiving of these CDs. The problem I have is getting the CD name from the CD. Using getDirectory I can map to the drive (e.g. E:, not a lot of use!) and get subfolder names etc but not the name of the CD (e.g BMBGJH_CD133). Can anyone help? Is there a 'get' command I can use? Of use maybe is that the name of the CD is burned as a text file on the CD; can I extract that?
Thanks in advance for your help.

Gareth
University of Leeds
Reply | Threaded
Open this post in threaded view
|

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

Pariksheet Nanda
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
Reply | Threaded
Open this post in threaded view
|

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

Gareth Howell
Hi Pariksheet,
Thanks for the response. I actually decided to generate a dialog so that the user could enter their CD name into the macro prior to it running the datebase macro. I guessed they would be putting individual CDs into the drive anyway so an additional step would not matter so much. Also they can add other info if they wished that would aid searching the database.
Thank you for your reply though, i'll keep a record of it if i need to develop it further.
BW
Gareth