Login  Register

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

Posted by Cammer, Michael on Apr 20, 2017; 7:18pm
URL: http://imagej.273.s1.nabble.com/How-do-you-open-files-that-have-brackets-in-the-filename-in-a-macro-tp5018579p5018582.html

I think I had this problem with files from a Zeiss lightsheet two years ago and I renamed the files in a cmd window (Win7) with something like:
ren ??????[??]*.tif ??????x??x*.tif

=*===========================================================*=
 Michael Cammer, DART Microscopy Laboratory, NYU Langone Medical Center
    Cell:  914-309-3270 (this is for calling, not texting)    Office: Skirball 2nd Floor main office, back right
      http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/
http://nyusackler.university-tour.com/15/34/core-laboratories-and-shared-resources/microscopy-core
http://nyusackler.university-tour.com/15/32/core-laboratories-and-shared-resources/introduction



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jeff C Hanson
Sent: Thursday, April 20, 2017 2:52 PM
To: [hidden email]
Subject: How do you open files that have brackets in the filename in a macro?

                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: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DQIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=2yYBHUtxfF67-1Pwyy2vuXjnxvRQDXJykI-H5qVvl0Y&s=w00Dih_BCgXNa9ZmLV9aERtTdvc4Z49p_5-zBvRI9oU&e= 

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

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