4
$\begingroup$

Probably a very easy question, but I could not find the answer, so it would be very nice if you can help me:

Let us say I have 10 files, all with the extension .dat. Using

data = Import[#, "Table"] & /@ FileNames["*.dat"]; 

I can import all .dat files in a folder.

However, I want Mathematica to order these .dat files by their alteration date just like I can do it under Windows with a right click > Sort by > alteration date. I want Mathematica to import the files in exactly this order. How might I do this?

$\endgroup$
7
$\begingroup$
dateOrdered = ((names = FileNames["*.dat"])[[Ordering[ FileDate[#, "Modification"] & /@ names]]]);

data = Import[#, "Table"] & /@ dateOrdered;

This will import with oldest modification date first, most recent last.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.