Hi Fred, both methods work in the unix command line: 1) quotes and 2) backslash before space:
1) touch -t 199911092233 "/private/tmp/AB C.jpg" 2) touch -t 199911092233 /private/tmp/AB\ C.jpg However, I don't succeed to do this from the exec() command. Best regards, Norbert On 30. Mar 2024, at 0:32, Fred Damen <[email protected]> wrote: > Greetings Norbert, > > The exec method is most likely reparsing its parameter as a unix command > line. Placing double quotes (") around the path should cause this parsing > to interpret the path as a single token and operate on it as you expect. > > try... > exec('touch -t 199911092233 ' + '"'+path+'"'); > or what ever the proper way to include " in strings... > > Fred > > > On Fri, March 29, 2024 3:01 pm, Norbert Vischer wrote: >> 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 >> > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
