I want to embed a generic definition for the image dir for saving files etc, inside a macro.
saveAs("Tiff", "D:\\Aug 2009\\Channa NReconB\\Colour.tif"); ie D:\\Aug 2009\\Channa NReconB, replaced by a generic term for the image dir last opened. Trolling thru the macros command library has not thrown up anything I can understand. Thanks, Teresa |
Hi,
Perhaps you are looking for ... sourceDir = File.directory(); You can call this after opening an image. Is that what you mean by "the image dir last opened"? Ben On Feb 13, 2010, at 12:53 AM, Teresa W wrote: > I want to embed a generic definition for the image dir for saving > files etc, > inside a macro. > > saveAs("Tiff", "D:\\Aug 2009\\Channa NReconB\\Colour.tif"); > > ie D:\\Aug 2009\\Channa NReconB, replaced by a generic term for the > image > dir last opened. Trolling thru the macros command library has not > thrown up > anything I can understand. > > Thanks, Teresa > -- > View this message in context: http://n2.nabble.com/souce-directory-code-for-writing-macro-tp4565178p4565178.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Hi Ben, could you show me how to embed this? Is this a line that goes at the start of the macro, or is it embedded within the line > e.g. *saveAs("Tiff", "File.dir\\Colour.tif");*? Thanks, Teresa
|
On Feb 13, 2010, at 7:12 AM, Teresa W wrote:
> Hi Ben, could you show me how to embed this? Is this a line that > goes at the > start of the macro, or is it embedded within the line > e.g. > *saveAs("Tiff", > "File.dir\\Colour.tif");*? Thanks, Teresa Hi, I think that you want something like below. You should edit the the first line to point an image that exists on your system. I print out the srcDir in the third line so you can see that it is just string. Also note that within the last command I use string math to concatenate the directory and the filename. You can see that Wayne has put in a wealth of file handling commands at ... http://rsb.info.nih.gov/ij/developer/macro/functions.html#F Cheers, Ben open("/Users/ben/Test.tif"); srcDir = File.directory(); print("srcDir=" + srcDir + " string length=" + lengthOf(srcDir)); outputFile = "Test-2.tif"; saveAs("Tiff", srcDir + outputFile); |
Hi Ben and Teresa,
I'm having similar issues writing to a specific folder. In my case I am duplicating ROIs from a stack and saving them as separate stacks, ideally in subfolders created in the parent. It all works well at the moment except the saving to the subfolders. Instead of ending up in the appropriate ones all the stack images get dumped in the parent. If either of you have any idea where the error lies in my code I'd be most grateful if you could point it out! Many thanks, Chris sdir = getDirectory("choose source directory "); n = roiManager("count"); for (i=0; i<n; i++) { roiManager("select", i); bee = "bee_"+i+"_"; ddir = sdir+bee; File.makeDirectory(ddir); run("Duplicate...", "title = ["+bee+"] duplicate range=1-3000"); run("Image Sequence... ", "format=TIFF name=["+bee+"] start=0 digits=4 save=["+ddir+"]"); close(); } -- View this message in context: http://n2.nabble.com/souce-directory-code-for-writing-macro-tp4565178p4611980.html Sent from the ImageJ mailing list archive at Nabble.com. |
In reply to this post by BenTupper
Hi Ben and Teresa,
I'm having similar issues writing to a specific folder. In my case I am duplicating ROIs from a stack and saving them as separate stacks, ideally in subfolders created in the parent. It all works well at the moment except the saving to the subfolders. Instead of ending up in the appropriate ones all the stack images get dumped in the parent. If either of you have any idea where the error lies in my code I'd be most grateful if you could point it out! Many thanks, Chris sdir = getDirectory("choose source directory "); n = roiManager("count"); for (i=0; i<n; i++) { roiManager("select", i); bee = "bee_"+i+"_"; ddir = sdir+bee; File.makeDirectory(ddir); run("Duplicate...", "title = ["+bee+"] duplicate range=1-3000"); run("Image Sequence... ", "format=TIFF name=["+bee+"] start=0 digits=4 save=["+ddir+"]"); close(); } |
Free forum by Nabble | Edit this page |