Page 1 of 1

How to get File Created Date from filesystem? [#18977 ]

Posted: Sun Apr 10, 2022 4:35 pm
by mms1234
Anyone know if it is possible to retrieve the date a file was created on the file system? I looked in app.filesystem and it doesn't look like there are any functions there that I can use for that.

I am converting a MM4 Vb script that I would use occasionally to fix the "Date Added" value on some older tracks that I've had in different folders on my PC and added into MM5 well after they were created (like years later). So I'd like to update the MM DB "Date Added" to be the date the file was created, not the date it was actually added/imported into MM5 DB.

For reference, in VBScript I could get the file object:
Set f = fso.GetFile(song.Path)
and then get the date created from that:
song.DateAdded = f.DateCreated

Re: How to get File Created Date from filesystem?

Posted: Mon Apr 11, 2022 5:55 am
by Ludek
Hi, thanks for feedback!

Tracking as https://www.ventismedia.com/mantis/view.php?id=18977 (to be added for the next 5.0.3 build).

Re: How to get File Created Date from filesystem? [#18977 ]

Posted: Wed Apr 13, 2022 6:41 pm
by Peke
Should be available as of 5.0.3.2614+

Re: How to get File Created Date from filesystem? [#18977 ]

Posted: Sat Apr 23, 2022 7:39 am
by mms1234
Just wanted to say thank you for adding this! I just tested on the beta build and it's working great. I was able to finish up that script I was working on. thanks so much for the quick turnaround on that. :D

Re: How to get File Created Date from filesystem? [#18977 ]

Posted: Sat Apr 23, 2022 4:49 pm
by Peke
Hi,
It was our pleasure.

Re: How to get File Created Date from filesystem? [#18977 ]

Posted: Thu Aug 18, 2022 11:54 am
by milos2000milos
Hi, could anyone give me any pointers on how to get the datecreated from what ive written below?

var fileInfo = await app.filesystem.getFileInfoAsync(item.path);

Once i've got the file info into a variable, how do I extract the date created from that? I'm unfamiliar with the Promises class so I've been struggling to do this myself.
Thanks

Re: How to get File Created Date from filesystem? [#18977 ]

Posted: Wed Aug 24, 2022 10:13 am
by Ludek
Hi,
as stated here: https://www.mediamonkey.com/docs/api/cl ... eInfoAsync
it results JSON.

So use something like this:

Code: Select all

async function getDateModified(path) {
   var jsonInfo = await app.filesystem.getFileInfoAsync(path);
   var info = JSON.parse(jsonInfo);
   return info.dateModified;
}
console.log( getDateModified('C:\\myFile.mp3'));