How to list the creation times for a bunch of files?

Posted by Ethan Cohen on
URL: http://imagej.273.s1.nabble.com/Parsing-a-log-file-to-extract-text-entries-of-File-Date-Modified-tp4552052p4646896.html

OK, I got it to list the file creation time for a single file in ImageJ Macroscript...

How to list the relative creation times for a bunch of files...to pipe to the TimeStamper?

Is there a GetFileDates command?


// OpenDialog Demo
//
// This macro demonstrates how do use the
// File.openDialog() macro function.

  path = File.openDialog("Select a File");
  //open(path); // open the file
  dir = File.getParent(path);
  name = File.getName(path);
  lastmod2 = File.lastModified(path);
  print("LastMod", lastmod2);
  print("Path:", path);
  print("Name:", name);
  print("Directory:", dir);
  list = getFileList(dir);


  print("Directory contains "+list.length+" files");

  // Display info about the files
  list = getFileList(dir);
  for (i=0; i<list.length; i++)
       print(list[i]+":  "+File.lastModified(list[i]));

Ethan.

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Rasband, Wayne (NIH/NIMH) [E]
Sent: Tuesday, March 06, 2012 4:22 PM
To: [hidden email]
Subject: Re: Parsing a log file to extract text entries of File Date Modified.

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