Posted by
Djoere Gaublomme on
Feb 10, 2015; 9:53am
URL: http://imagej.273.s1.nabble.com/batch-importing-files-double-backslashes-tp5011545.html
Hello,
I have run into a problem which might be quite trivial.
I am trying to batch process a folder, for which I used the 'Process
Folder' template macro code (I have copy pasted it at the bottom of
this message).
The first command is to import the file with Bioformats Importer,
however I get an error: ")" expected .
The command is:
run("Bio-Formats Importer", "open=["input + file"] autoscale
color_mode=Default display_metadata view=Hyperstack stack_order=XYCZT");
Where input is the path from getDirectory, and file is the filename.
I assume I am making a basic mistake here somewhere.
I thought the problem might be due to a case of single or double
backslashes, as when you ' print(input + file) ', in the log there are
only single backslashes visible in the path name (but perhaps
internally the string does contain 2 backslashes?)
I looked at some suggestions online and tried replacing the input
string as follows:
inputReal = replace(input,"\\" , "\\\\")
This gave the error: //java.util.regex.PatternSyntaxException:
Unexpected internal error
near index 1
or
inputReal = replace(input,"\\" , "/")
This gave the error: ' ";" expected ' , when trying to ' print(inputReal); '
Any suggestions?
Thanks
Djoere
'Process Folder' template macro code :
input = getDirectory("Input directory");
output = getDirectory("Output directory");
Dialog.create("File type");
Dialog.addString("File suffix: ", ".lsm", 5);
Dialog.show();
suffix = Dialog.getString();
processFolder(input);
function processFolder(input) {
list = getFileList(input);
for (i = 0; i < list.length; i++) {
if(endsWith(list[i], "/"))
processFolder("" + input + list[i]);
if(endsWith(list[i], suffix))
processFile(input, output, list[i]);
}
}
function processFile(input, output, file) {
// do the processing here by replacing
// the following two lines by your own code
print("Processing: " + input + file);
print("Saving to: " + output);
print(output);
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html