converting images and saving to a new location whilst retaining file name?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

converting images and saving to a new location whilst retaining file name?

ctsiantar
I am relatively rusty on my macros, but I have so far produced a program that will go through a folder of images, and convert them to bitmaps to be saved along with a .txt file containing information which will be displayed in a cataloguing program

My only problem is that it only works with the file name i specify, and cant retain the original filename of the image, here is the code for saving the text file, the image file is the same but with BMP instead of text obviously
;saveAs("Text", "D:\\BioimagingCatalogue\\Archive\\ImageJ\\file");
file is the current filename

I cant figure out if its possible to save the filename as a value and then insert that into the pathway, or use a function in the pathway
alternatively if it was possible to duplicate the image as a bitmap and then move it to a new folder, that would work too, as long as the file name is kept, and it can all be done inside one macro
Reply | Threaded
Open this post in threaded view
|

Re: converting images and saving to a new location whilst retaining file name?

Krs5
You could try something like

file =  File.nameWithoutExtension;
selectWindow("your text file");
saveAs("Text", "D:\\BioimagingCatalogue\\Archive\\ImageJ\\"+file);
selectWindow("your BMP file");
saveAs("bmp", "D:\\BioimagingCatalogue\\Archive\\ImageJ\\"+file);

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Centre for Core Biotechnology Services
University of Leicester
http://www.le.ac.uk/biochem/microscopy/home.html 

Fluorescence microscopy workshops 20-24 August 2012: http://www.le.ac.uk/biochem/microscopy/workshop2012.html 


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of ctsiantar
Sent: 18 July 2012 15:58
To: [hidden email]
Subject: converting images and saving to a new location whilst retaining file name?

I am relatively rusty on my macros, but I have so far produced a program that
will go through a folder of images, and convert them to bitmaps to be saved
along with a .txt file containing information which will be displayed in a
cataloguing program

My only problem is that it only works with the file name i specify, and cant
retain the original filename of the image, here is the code for saving the
text file, the image file is the same but with BMP instead of text obviously
;saveAs("Text", "D:\\BioimagingCatalogue\\Archive\\ImageJ\\file");
file is the current filename

I cant figure out if its possible to save the filename as a value and then
insert that into the pathway, or use a function in the pathway
alternatively if it was possible to duplicate the image as a bitmap and then
move it to a new folder, that would work too, as long as the file name is
kept, and it can all be done inside one macro

--
View this message in context: http://imagej.1557.n6.nabble.com/converting-images-and-saving-to-a-new-location-whilst-retaining-file-name-tp4999481.html
Sent from the ImageJ mailing list archive at Nabble.com.

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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: converting images and saving to a new location whilst retaining file name?

ctsiantar
thanks very much, i ended up working it through with a friend who had a better idea about this kind of thing than me and we came to pretty much the same conclusion. The macro is running great now.

Thanks again
Christian Tsiantar