Login  Register

Re: Chose only specific file on a folder

Posted by Michael Schmid on May 30, 2008; 4:05pm
URL: http://imagej.273.s1.nabble.com/Chose-only-specific-file-on-a-folder-tp3696102p3696107.html

Hi Zhengyu,

ImageJ Macros are not Java, but an own macro language that is
similar to Java. See the documentation on the ImageJ Web site.

In the macro language there is no "contains", instead you can use
   indexOf(string, substring)>=0

http://rsb.info.nih.gov/ij/developer/macro/functions.html#indexOf

Michael
________________________________________________________________

On 30 May 2008, at 17:53, Pang, Zhengyu (GE, Research) wrote:

> Michael and Christophe,
>
> Thanks for pointing me to the right direction. endsWith function is  
> what
> I need for this purpose.
>
> I previously used a function "contains", but it did not work. Do I  
> need
> to include some package to get this function work? I have  
> background for
> C language, but not for Java.
>
> Thanks,
>
> Zhengyu
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Michael Schmid
> Sent: Friday, May 30, 2008 4:45 AM
> To: [hidden email]
> Subject: Re: Chose only specific file on a folder
>
> Hi Zhengyu, Christophe,
>
> it very simple: The ImageJ macro language has an "endsWith" function:
> http://rsb.info.nih.gov/ij/developer/macro/functions.html#E
>
> if (endsWith(filename, ".jpg")) ...
> else if (endsWith(filename, ".txt")) ...
> else if (endsWith(filename, ".zvd")) ...
>
> For the loop, see, e.g., the ListFilesRecursively macro
> http://rsb.info.nih.gov/ij/macros/ListFilesRecursively.txt
>
> Michael
> ________________________________________________________________
>
> On 30 May 2008, at 09:07, Christophe Leterrier wrote:
>
>> Hi Zhengyu,
>>
>> Just get all your file names as an array using getFileList() and the
>> loop on all names to detect the last three characters of the names
>> using substring(name, 0, LengthOf(name)-4) (I could I've messed the
>> indexes !). Store that as a new extensions[] array and then put your
>> whole macro in a for+if loop (loop an all extensions, test if
>> extension is .tif).
>>
>> Sorry I don't have a macro at hand that does that to give you the  
>> code
>
>> directly...
>>
>> Christophe
>>
>> On Fri, May 30, 2008 at 6:05 AM, Pang, Zhengyu (GE, Research)
>> <[hidden email]> wrote:
>>> Dear all,
>>>
>>> I have made a macro to batch process images under a folder. But some
>>> files are not images and I need to ignore these files. How do I do
>>> it? I have used a function of getFileList() to read all files, but
>>> how do I ignore some files ending with".zvd" OR ".archive"? Thanks
>>> for your help.
>>>
>>> Zhengyu
>>>
>>>>               g Global Research Center
>>>>
>>>> ___________________________________________________________________
>>>> _
>>>> __
>>>>
>>>>           Zhengyu Pang, Ph.D.
>>>                        Bioanalytics and Protein Science Laboratory
>>>                        Biosciences Global Technology Organization
>>>>               One Research Circle, K1 5B37A
>>>>               Niskayuna, NY12309
>>>>               * [hidden email]
>>>>               *(518) 387-4015
>>>>
>>>>
>>>