Time stamp of files?

Hi,

I'm trying to extract the time stamps for a list of files, but don't know how to do that. It's easy to list the files using the "list files" node, but it doesn't allow you to pull in file properties. I tried using the "external tool" node, but can't get it to work.

Does anyone have any tips on how to get to this info? 

Thanks,

Natasja

 

We added this functionality to the corresponding "List folders" node in our community contribution a while back because we used it so often as a next step.  Maybe the KNIME 'core' List Files should also be updated to add it (feature request!).

In the meantime, we use a Java Snippet (Simple):

File file=new File($Folder Column$);
long ms=file.lastModified();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd;HH:mm:ss.S");
Date resultdate = new Date(ms);
String r = sdf.format(resultdate);
return r;

(Return type as String)

Followed by a String to Date/Time node.

Or, slightly shorter, in a Java Snippet, add a new output column of DateAndTimeType and use:

File f = new File(c_Location);
Date d = new Date(f.lastModified());
out_DateTime = d;

(Where c_Location is the locatin column of list files, and out_dateTime with whatever your output column is called)

The "File Meta Info" node from the filehandling extension does exactly what you want.

2 Likes

Excellent - I will keep that one in mind too!

Steve