remove extension image's filename

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

remove extension image's filename

Eric BADEL-2
Hi all,
It is probably so simple ! Sure, I should find in the archives but I
searched and I found only a tricky method.
Let's open an image and get its title (title=getTitle()). Then, do many
things and measurements with it than finally save the results and an another
resulting image with the same name.

Example:
The initial image I open is "toto.tif"
I want to save final results as "toto.xls" (and not "toto.tif.xls")
and an another resulting image as "toto_loc.tif" (and not "toto.tif_loc.tif")

For that, we need to get "toto".
Thank you
Eric
Reply | Threaded
Open this post in threaded view
|

Re: remove extension image's filename

Thomas Boudier
Hi,

Something I use a lot for that is : replace(string, old, new)

for instance xls_name=replace(title,".tif",".xls");

Thomas


Eric BADEL a écrit :

> Hi all,
> It is probably so simple ! Sure, I should find in the archives but I
> searched and I found only a tricky method.
> Let's open an image and get its title (title=getTitle()). Then, do many
> things and measurements with it than finally save the results and an another
> resulting image with the same name.
>
> Example:
> The initial image I open is "toto.tif"
> I want to save final results as "toto.xls" (and not "toto.tif.xls")
> and an another resulting image as "toto_loc.tif" (and not "toto.tif_loc.tif")
>
> For that, we need to get "toto".
> Thank you
> Eric
>
>

--
   /**********************************************************/
      Thomas Boudier, MCU Université Pierre et Marie Curie,
      IFR 83. Bat B 7ème étage, porte 709, Jussieu.
      Tel : 01 44 27 20 11  Fax : 01 44 27 22 91
/*******************************************************/
Reply | Threaded
Open this post in threaded view
|

Re: remove extension image's filename

Christopher Coulon-2
In reply to this post by Eric BADEL-2
> It is probably so simple ! Sure, I should find in the archives but I
> searched and I found only a tricky method.
> Let's open an image and get its title (title=getTitle()). Then, do many
> things and measurements with it than finally save the results and an another
> resulting image with the same name.
>
> Example:
> The initial image I open is "toto.tif"
> I want to save final results as "toto.xls" (and not "toto.tif.xls")
> and an another resulting image as "toto_loc.tif" (and not "toto.tif_loc.tif")
>
> For that, we need to get "toto".

Eric,

You can use something like this:

            name = getTitle;
            dotIndex = indexOf(name, ".");
            title = substring(name, 0, dotIndex);

Now your name will be toto.tif and your title will be toto.  Use the title
for your saves.

Chris Coulon
       

The GAIA Group
 Global Automated Image Analysis

We help Researchers help themselves!
Find out about Online Tutoring for ImageJ

Christopher Coulon, Ph.D., Founder
http://gaiag.net
[hidden email]