Posted by
lechristophe on
Oct 15, 2009; 10:30am
URL: http://imagej.273.s1.nabble.com/open-next-tp3690744p3690748.html
something like
sdir = getDirectory("Choose Source Directory ");
ddir = getDirectory("Choose Destination Directory ");
names= getFileList(sdir);
for (i=0; i<names.length, i++) {
open(sdir+names[i]);
run("Rolling Ball Background", "rolling=50");
save(ddir+names[i]);
}
as a side note, if it is just for a simple operation such as backround
substraction, the easiest way is to open all your images from source
directory as a stack, apply the operation on the whole stack, and then
save them as an image sequence using "Use labels as file names" option
in your destination directory, so you will get the modified images in
your destination directory, with the original names, no macro required
(as long as the memory allow you to open all your directory images as
one stack).
Christophe
On Thu, Oct 15, 2009 at 12:23 PM, Christophe Leterrier
<
[hidden email]> wrote:
> Get the user to select both source and destination directories at the beginning
> get the names of all files in the directory using getfilelist and
> store them in an array
> then loop on this array using indexes and names stored, using open()
> and save() with full path names on the source and destination
> directory respectively
> it can be good to enclose the loop in a condition testing the image
> file extension (.tif or what you use), to avoid trying to open
> non-image files if there are any in the source directory.
>
> Christophe
>
> On Thu, Oct 15, 2009 at 12:08 PM, Andrew Bell <
[hidden email]> wrote:
>> Hello,
>>
>> I want a macro to open an image, perfrom an operation, save it to another
>> location, and open the next image in the original folder. Is this possible
>> without the user having to specify the source folder each time?
>>
>> This is where i am at so far:
>>
>>
>> dir = getDirectory("Choose Destination Directory ");
>> open();
>> name = dir+getTitle();
>> run("Rolling Ball Background", "rolling=50");
>> save(name+".tif");
>> run("Open Next");
>>
>> This macro only opens the next file in the destination folder. How can I
>> specify to open the next file in the source folder?
>>
>> Any suggestions warmly welcomed!
>>
>> Regards,
>>
>> Andrew
>>
>