Posted by
Ethan Cohen on
URL: http://imagej.273.s1.nabble.com/Parsing-a-log-file-to-extract-text-entries-of-File-Date-Modified-tp4552052p4642586.html
Wayne:
1. OK, on ImageJ (Fiji) in WinXP, when I execute your imageJ macroscript file it does not work, and no file open is requested.
2. If I open an image series stack, and then run the script it works, I get the filenames, but all the file modified times are just zeros.
3. If I run the following ImageJ macroscript, I can open a file, but then all the times are zero from 1969... Sound familiar?
// 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);
print( File.dateLastModified(name));
print (File.lastModified(name));
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.dateLastModified(dir+list[i]));
THE IMAGEJ LOG...I will spare you the redundencies...
Wed Dec 31 19:00:00 EST 1969
0
Path: C:\Documents and Settings\edc\Desktop\OCT\100819\Run1-37uA\OCT_153014.bmp
Name: OCT_153014.bmp
Directory: C:\Documents and Settings\edc\Desktop\OCT\100819\Run1-37uA
Directory contains 85 files
0071-0145-0368.roi: Wed Dec 31 19:00:00 EST 1969
image153000.bmp: Wed Dec 31 19:00:00 EST 1969
image160022.bmp: Wed Dec 31 19:00:00 EST 1969
M1-37uA.avi: Wed Dec 31 19:00:00 EST 1969
PC specific java date problem?
I can get the times (in seconds) in a little Python script though. Like:
import os
filename = "C:/Documents and Settings/edc/Desktop/OCT/100819/Run1-37uA/"
statbuf = os.stat(filename)
print "Modification time:",statbuf.st_mtime
Started MacroTime.py at Wed Mar 21 18:16:35 EDT 2012
Modification time: 1332360656
4. Oddly in your FileDemo.txt it works, but you have to create the file.
There seems to be a discussion from 2008 about this issue here:
http://imagej.1557.n6.nabble.com/File-creation-date-in-a-macro-td3694500.htmlEthan
-----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