Re: Parsing a log file to extract text entries of File Date Modified.

Posted by Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/Parsing-a-log-file-to-extract-text-entries-of-File-Date-Modified-tp4552052p4552567.html

On Mar 6, 2012, at 12:10 PM, Cohen, Ethan D wrote:

> I have tried the FileDemo.txt macro to open a series of image files.
>
> You get output that looks like this in the ImageJ log file.
>
> image2.tif: 524456  Tue Mar 06 11:43:52 EST 2012
>
> 1.      What I want to do is parse this file for the file date modified info 11:43:52  and convert it from characters to numbers and then into seconds.
>
> 2.      How do I go about doing this? I am new to javascript/ ImageJ macros.
>
> 3.      Is there an existing macro/ImageJ function or script I should know about?  Time Stamp only gives fixed time intervals not real time intervals.
>
> 4.      Does File, Import Sequences, save the file Date Modified info of each file in a hidden stack I can access?

Here is an example macro that opens a series of images and displays the modification date for each file:

  dir = getDirectory("home")+"images"+File.separator;
  run("Image Sequence...", "open=&dir sort");
  for (i=1; i<=nSlices; i++) {
     setSlice(i);
     name = getMetadata("label");
     date = File.dateLastModified(dir+name);
     words = split(date, ": ");
     hour = parseInt(words[3]);
     min = parseInt(words[4]);
     sec = parseInt(words[5]);
     print(name, hour, min, sec);
  }

-wayne