Login  Register

Re: Recursive processing of a directory not working correctly

Posted by Jan Eglinger on May 21, 2014; 11:39am
URL: http://imagej.273.s1.nabble.com/Recursive-processing-of-a-directory-not-working-correctly-tp5007797p5007823.html

Hi Matt and Michael,

as I pointed out on my answer to your question on stackoverflow.com [1]
a few days ago, Fiji's script editor contains a macro template for
processing folders recursively. You can open it in the script editor via
'Templates > Macros > Process Folder'.

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

I included Michael's suggestion in a pull request to said template:
https://github.com/fiji/Script_Editor/pull/1

Thanks and cheers,
Jan

[1]: http://stackoverflow.com/a/23709728/1919049



On 21.05.2014, 9:39 AM, Michael Schmid 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