Login  Register

How do you open files that have brackets in the filename in a macro?

Posted by jchanson on Apr 20, 2017; 6:51pm
URL: http://imagej.273.s1.nabble.com/How-do-you-open-files-that-have-brackets-in-the-filename-in-a-macro-tp5018579.html

                I'm stumped.  I have a batch of files that I want to analyze with a macro.  When the macro tries to open the files, it cuts the filename off at the close bracket (]).  I tried throwing in a \ to escape the embedded brackets, but, it didn't help.
                Is there a way to open the files in a way that doesn't treat the brackets as a special character?  Or, is there a way to get it to ignore the brackets in the middle of the filename?

Thanks,
Jeff

ps - Here's an example of what I was trying to do...

file = "awkward_filename_[39254,8006]_component_data.tif";
bracketPattern = "([\\[\\]])";
addBackslashPattern = "\\\\$1";
escapedFile = replace(file, bracketPattern, addBackslashPattern);

// This throws an exception, because it cuts the filename off at the "]" -- and says the file does not exist
//run("Bio-Formats", "open=["+file+"] color_mode=Default open_all_series view=Hyperstack stack_order=XYCZT");
// This didn't fix it.  :-(
run("Bio-Formats", "open=["+escapedFile+"] color_mode=Default open_all_series view=Hyperstack stack_order=XYCZT");

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html