Posted by
Michael Entrup on
Mar 14, 2017; 2:44pm
URL: http://imagej.273.s1.nabble.com/File-nameWithoutExtension-tp5018290p5018292.html
Hi Kees,
the source code might help to understand what is happening:
```Java
String name = OpenDialog.getLastName();
if (name==null) return "";
int dotIndex = name.lastIndexOf(".");
if (dotIndex>=0 && (name.length()-dotIndex)<=5)
name = name.substring(0, dotIndex);
return name;
```
It is necessary to use the OpenDialog to get a result from
nameWithoutExtension(). ``run("Blobs (25K)")`` and manually selecting
the sample image from the "File > Open Samples" menu use a different
mechanism to open an image.
Best regards
Michael
On 14.03.2017 15:01, Straatman, Kees (Dr.) wrote:
> Dear list and Wayne,
>
> I recently noticed some problems with the function File.nameWithoutExtension()
>
> If I open Fiji or ImageJ and run the macro code:
>
> run("Blobs (25K)");
> title=File.nameWithoutExtension();
> print(title);
>
> I get as result: "test_"
>
> If I give this macro a name it will give as result the macro name.
>
> I can repeat this multiple times, the result is the same.
>
> If I open manually the blobs sample file, and run line 2 and 3 from the macro I get the same results. If I open a locally saved file the result is "blobs". If I now run the 3 line macro again the results is "blobs", as expected
>
> However, if I close Fiji, restart and open my images and run line 2 and 3 from the macro I get the macro name as result again.
>
> Can anybody confirm this behaviour?
>
> Best wishes
>
> Kees
>
> University of Leicester
>
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html