Login  Register

Re: open batch

Posted by lechristophe on Jul 28, 2008; 10:35am
URL: http://imagej.273.s1.nabble.com/open-batch-tp3695502p3695504.html

Dear Johannes,

Sorry for being inaccurate, the proper File command is
File>Import...>Image Sequence as explained in the ImageJ documentation
:
http://rsbweb.nih.gov/ij/docs/menus/file.html#import

As regards a macro for opening every file in a chosen folder, try this code :

macro "Open All Files" {
DIR=getDirectory("Choose Folder");
NAMES=getFileList(DIR);
for (i=0; i<NAMES.length; i++) {
open(DIR+NAMES[i]);
}
}

Beware, the macro will throw an error and exit if something in the
folder is not recongnized as an ImageJ compatible format, so you have
to make sure you only have images in the folder.

The code is very simple, it just asks a directory (getDirectory) with
its path stored as DIR, then store an array NAMES containing all file
names in the folder DIR (getFileList), then loop on from the first to
the last element of NAMES and opens the images, which path is created
by concatenating DIR and the element NAMES[i]. Just go to
http://rsbweb.nih.gov/ij/developer/macro/macros.html and
http://rsbweb.nih.gov/ij/developer/macro/functions.html to get started
with writing simple macros, it is not complicated and quite powerful.


Christophe


On Mon, Jul 28, 2008 at 12:21, Johannes Breu <[hidden email]> wrote:

>
> Thanks for answering. Yes, I mean folder not file but I am not experienced enough to implement your suggestions.
>
>>
>>
>> I guess you mean open all images inside a "folder" rather than a file ? If
>> so, just use the File>Open...>Open File Sequence command if all your images
>> have the same format.
>
> I did not find this possibility to open images (imageJ 1.40g).
>
>>
>> If not, you coud use a simple macro using getDirectory
>> and getFileList and a loop on all files found (optionnally testing for an
>> image extension such as .tif).
>
> I was not able to find these macros <http://rsb.info.nih.gov/ij/macros/> . Is there another suitable address for macros? Originally I was optimistic to detect anything useable because my purpose seemed quite trivial. But either it is hard find or I am to unexperienced to reshape the macros.
>
> Thanks
> Johannes
>>
>> Christophe
>>
>>
>> On Sun, Jul 27, 2008 at 23:21, Johannes Breu <[hidden email]> wrote:
>>
>> > Hello,
>> >
>> > I am looking for a macro to open all images within a file. I found some
>> > macros dealing with batches but I just want: Open all images in the file I
>> > selected.
>> >
>> > Thanks
>> > Johannes
>> >
>