Posted by
Kenton Arkill on
May 21, 2014; 9:23am
URL: http://imagej.273.s1.nabble.com/Recursive-processing-of-a-directory-not-working-correctly-tp5007797p5007822.html
Hi Matt
Not sure if it helps but I use the following for a very similar problem
with .dm3 files where I want to make jpg mini versions for people (I've
taken out the size change bit):
dir = getDirectory("Choose a Directory");
list = getFileList(dir);
setBatchMode(true);
for (i=0; i<list.length; i++) {
path = dir+list[i];
if(endsWith(path, ".dm3")){
open(path); // OR OTHER IMPORT PLUGGIN
run("Enhance Contrast", "saturated=3"); // Change the 0.35 to a higher
number if jpgs too gray eg 2 or 5
// OR OTHER TRANSFORMATIONS
dotIndex = lastIndexOf(path, ".");
if (dotIndex!=-1){
path = substring(path, 0, dotIndex); // remove extension
save(path+".jpg");
}
close();
}
}
showStatus("Done");
On 21 May 2014 08:39, Michael Schmid <
[hidden email]> wrote:
> Hi Matt,
>
> you can put square brackets around the directory+filename, then spaces
> don't do any harm.
>
> run("Bio-Formats Windowless Importer", "open=["+inBase + path+"]
> color_mode=Default view=Hyperstack stack_order=XYCZT");
>
> If you have
> open=C:\Users\Matt Jacobs\Desktop\K259_tlx3cre_Rabies\whateverFile.vsi
> the space is taken as a delimiter,
> open=C:\Users\Matt
> and the next statement would be
> Jacobs\Desktop\K259_tlx3cre_Rabies\whateverFile.vsi
> As the second part is not any keyword, it is probably ignored.
> So it should be
> open=[C:\Users\Matt Jacobs\Desktop\K259_tlx3cre_Rabies\whateverFile.vsi]
>
> ---
>
> One more point:
> in your macro, you have
> if (endsWith(path, "/"))
> to check whether this is a directory.
> It would be better to use
> if(File.isDirectory(path))
> The current code seems to work also under Windows because ImageJ replaces
> the backslash by a slash, but relying on this is not a nice solution.
>
> Michael
> ________________________________________________________________
> On May 20, 2014, at 22:42, matsojr22 wrote:
>
> > Let me also clarify that I am currently testing the macro on files I have
> > copied to the desktop...
> >
> > Input directory is C:\Users\Matt Jacobs\Desktop\K259_tlx3cre_Rabies\
> > Output directory is C:\Users\Matt Jacobs\Desktop\fiji output\
> >
> > Also, I'm just recognizing that the error is not telling me that
> > "C:\Users\Matt Jacobs\" does not exist... it is telling me the file
> > "C:\Users\Matt" does not exist...
> >
> > Am I having trouble just because I have spaces in the directory?
> >
> > Thanks again,
> > Matt
> >
> >
> >
> > --
> > View this message in context:
>
http://imagej.1557.x6.nabble.com/Recursive-processing-of-a-directory-not-working-correctly-tp5007797p5007811.html> > Sent from the ImageJ mailing list archive at Nabble.com.
> >
> > --
> > ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html