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

To discuss development of addons / skins / customization of MediaMonkey.

Moderators: jiri, drakinite, Addon Administrators

mms1234

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

Post 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
Ludek
Posts: 4959
Joined: Fri Mar 09, 2007 9:00 am

Re: How to get File Created Date from filesystem?

Post 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).
Peke
Posts: 17484
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

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

Post by Peke »

Should be available as of 5.0.3.2614+
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
mms1234

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

Post 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
Peke
Posts: 17484
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

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

Post by Peke »

Hi,
It was our pleasure.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
milos2000milos
Posts: 1
Joined: Sun Jul 10, 2022 9:19 am

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

Post 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
Ludek
Posts: 4959
Joined: Fri Mar 09, 2007 9:00 am

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

Post 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'));
Post Reply