Login  Register

Re: batch importing files - double backslashes?

Posted by Djoere Gaublomme on Feb 10, 2015; 10:41am
URL: http://imagej.273.s1.nabble.com/batch-importing-files-double-backslashes-tp5011545p5011547.html

OK, that was it.

Thanks a lot, Jan !

Djoere

Quoting BioVoxxel <[hidden email]>:

> Hi Djoere,
>
> The error occurs because you are missing the connecting "+"-signs:
>
> your code:
> run("Bio-Formats Importer", "open=["input + file"] autoscale
> color_mode=Default display_metadata view=Hyperstack stack_order=XYCZT");
>
> corrected code:
> run("Bio-Formats Importer", "open=[" + input + file + "] autoscale
> color_mode=Default display_metadata view=Hyperstack stack_order=XYCZT");
>
> This should solve the problem.
>
> If you want to have the file and folder separators it might be better to
> use the following command
>
> variable1 + file.separator + variable2
>
> The command "file.separator" gives you the correct separators no matter in
> which system you are running the macro. Otherwise, it will be running only
> on Windows or only on Mac since the file separators used in IJ are
> different in the two systems.
>
> cheers,
> Jan
>
> 2015-02-10 10:53 GMT+01:00 Djoere Gaublomme <[hidden email]>:
>
>> 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
>>
>
>
>
> --
>
> CEO: Dr. rer. nat. Jan Brocher
> phone:  +49 (0)6234 917 03 39
> mobile: +49 (0)176 705 746 81
> e-mail: [hidden email]
> info: [hidden email]
> inquiries: [hidden email]
> web: www.biovoxxel.de
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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