Login  Register

Re: Chose only specific file on a folder

Posted by Michael Schmid on May 30, 2008; 8:45am
URL: http://imagej.273.s1.nabble.com/Chose-only-specific-file-on-a-folder-tp3696102p3696105.html

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
>>>
>>>
>>