Login  Register

Re: Apply to all files...

Posted by Albert Cardona-2 on Apr 06, 2011; 1:09pm
URL: http://imagej.273.s1.nabble.com/Apply-to-all-files-tp3685140p3685143.html

2011/4/6 Wilson R S (AT) <[hidden email]>:
> I am thinking someone would probably have already wrote this code/macro, but can't find it...
>
> I want to apply a macro to all files within a certain folder and all its subfolders. I can see how this works in theory with getFileList(Directory), but just can't seem to get the code quite rite.
>
> Any help would be much appreciated.
>
> Rhod


Considering you want subdirectories as well, I'd do it with a python script:

basedir = "/path/to/root/dir/"

for root, dirs, files in os.walk(basedir):
  for file in files:
    # do something to each file

See examples in Jython here:

http://pacific.mpi-cbg.de/Jython_Scripting



--
http://albert.rierol.net
http://www.ini.uzh.ch/~acardona