Hello all,

I would like to change an image without loosing its creation date. I succeeded 
to do this as long as the path name has no space. But I cannot guarantee 
space-free path names. 

The following macro creates an image, saves it, and then sets its date to year 
= 1999.
However, in the second run, it fails because the path contains a space. 
Instead, a file called "AB" with zero bytes is created.
How can I handle path names that contain a space?
I tried this on MacOS.

Best regards,
Norbert


//===================
print("\\Clear");
close("ABC*");
close("AB C*");
for(n=1; n<=2; n++){
        if(n==1)
                title = "ABC.jpg";//without space
        if(n==2)
                title = "AB C.jpg";//with space
        print("title=", title);
        newImage(title, "8-bit ramp", 400, 200, 1);
        path = getDir("temp") + title;

        saveAs("Jpeg", path);
        date1 = File.dateLastModified(path);
        print("date1=", date1);

        exec('touch -t 199911092233 ' + path);
        date2 = File.dateLastModified(path);
        print("date2=", date2);
}
selectWindow("Log");
run("temp"); //show in Finder

//===================

output:

title= ABC.jpg
date1= Fri Mar 29 20:36:37 CET 2024
date2= Tue Nov 09 22:33:00 CET 1999
title= AB C.jpg
date1= Fri Mar 29 20:36:37 CET 2024
date2= Fri Mar 29 20:36:37 CET 2024

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

Reply via email to