Posted by
Justin McGrath on
Sep 26, 2007; 3:19pm
URL: http://imagej.273.s1.nabble.com/Batch-rename-DICOM-files-with-header-info-tp3698314p3698317.html
According to the reference
"The file or directory must be in the user's home directory, the
ImageJ directory or the temp directory."
You can just put the files under any directory named ImageJ and it
will work. There is also now an exec() macro function that will
execute system commands. I haven't tried it, but you may be able to
use that instead.
Justin
On 9/26/07, Michael Doube <
[hidden email]> wrote:
> Hi All
>
> I was hoping this would be a quick job but I am stuck. I have a
> directory full of DICOM images and matching bitmap thumbnails, both
> named with a timestamp by the capture software. I'd like to rename all
> the DICOM files and matching BMP's with the string contained in header
> 0010,0010. I can get the string, but don't seem to be able to rename
> the files with it. Any help appreciated,
>
> Mike
>
> macro:
> ------------------------------------
> setBatchMode(true);
> open();
> path = File.directory();
> tag = "0010,0010";
> close();
>
> function getTag(tag) {
> info = getImageInfo();
> index1 = indexOf(info, tag);
> if (index1==-1) return "";
> index1 = indexOf(info, ":", index1);
> if (index1==-1) return "";
> index2 = indexOf(info, "\n", index1);
> value = substring(info, index1+1, index2);
> return value;
> }
>
> list = getFileList(path);
> showStatus("Getting File List...");
> for (i=0; i<list.length; i++){
> if(endsWith(list[i], '.dcm')){
> open(list[i]);
> newtitle = replace(getTag(tag),'^','_');
> newtitle = replace(newtitle, ' ', '_');
> newtitle = substring(newtitle, 1, lengthOf(newtitle)-1);
> print(newtitle);
> close();
> File.rename(list[i], path+newtitle+".dcm");
> thumbnail = replace(list[i], ".dcm", ".bmp");
> File.rename(thumbnail, path+newtitle+".bmp");
> }
> }
> ----------------------------------
>