How to prefix with the EML file's Date header field?

Post any Bulk Rename Utility support requirements here. Open to all registered users.

How to prefix with the EML file's Date header field?

Postby chrisjj » Mon Mar 31, 2025 7:32 pm

Please?

Help says "The Item Date is the primary date of interest for an item" but "Item Date" does not equal Date. It might be timezone-converted Date and/or Received.

I do need Date itself, ideally with custom format.

Thanks.
chrisjj
 
Posts: 37
Joined: Wed Mar 30, 2011 5:26 pm

Re: How to prefix with the EML file's Date header field?

Postby Admin » Mon Mar 31, 2025 10:47 pm

What does the Windows File Property -> Details tab show for the EML file? Bulk Rename will match that.
Admin
Site Admin
 
Posts: 2972
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to prefix with the EML file's Date header field?

Postby chrisjj » Mon Mar 31, 2025 11:02 pm

Admin wrote:What does the Windows File Property -> Details tab show for the EML file?


I find no such command, but "Show List of File Properties" shows a date that's timezone-converted.

Admin wrote:Bulk Rename will match that.


Yup. But that's not Date:. I do need Date itself, ideally with custom format.

Thanks.
chrisjj
 
Posts: 37
Joined: Wed Mar 30, 2011 5:26 pm

Re: How to prefix with the EML file's Date header field?

Postby Admin » Tue Apr 01, 2025 5:21 am

You can adapt the date with BRU javascript, can you send a sample file to support via email? thanks
Admin
Site Admin
 
Posts: 2972
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to prefix with the EML file's Date header field?

Postby chrisjj » Tue Apr 01, 2025 9:44 am

Admin wrote:You can adapt the date with BRU javascript, can you send a sample file to support via email? thanks

Done. Thanks.
chrisjj
 
Posts: 37
Joined: Wed Mar 30, 2011 5:26 pm

Re: How to prefix with the EML file's Date header field?

Postby chrisjj » Thu Jul 03, 2025 11:59 am

PS Support by email suggested "shift the time by a delta amount with Javascript" but unfortunately this will not in general solve the discrepancy, since the Date: timezone may vary.

If anyone has found a solution, please say.
chrisjj
 
Posts: 37
Joined: Wed Mar 30, 2011 5:26 pm

Re: How to prefix with the EML file's Date header field?

Postby Admin » Sun Jul 06, 2025 1:22 am

The new version 4.0.0.9 will have a fileMatch function to extract the date from the EML file and then it can be applied to the file name.
Admin
Site Admin
 
Posts: 2972
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to prefix with the EML file's Date header field?

Postby chrisjj » Sun Jul 06, 2025 10:49 am

Admin wrote:The new version 4.0.0.9 will have a fileMatch function to extract the date from the EML file and then it can be applied to the file name.


That's great. Thanks. I hope the implementation will recognise that a Date: field line can appear in EML body as well as header and of course only the header's is the actual message date.

Any idea roughly when this will release?
chrisjj
 
Posts: 37
Joined: Wed Mar 30, 2011 5:26 pm

Re: How to prefix with the EML file's Date header field?

Postby Admin » Tue Jul 08, 2025 12:40 am

Yes, there will be a new function fileMatch which can extract text from a file based on RegEx.
Using the JS assistant https://www.bulkrenameutility.co.uk/js/ it should be easy to use.
Admin
Site Admin
 
Posts: 2972
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to prefix with the EML file's Date header field?

Postby chrisjj » Tue Jul 08, 2025 11:26 am

Admin wrote:Yes, there will be a new function fileMatch which can extract text from a file based on RegEx.
Using the JS assistant https://www.bulkrenameutility.co.uk/js/ it should be easy to use.


Thanks, but JS?? Will it be available to Home/Academic users?
chrisjj
 
Posts: 37
Joined: Wed Mar 30, 2011 5:26 pm

Re: How to prefix with the EML file's Date header field?

Postby Admin » Wed Jul 09, 2025 3:04 am

JavaScript in BRU is available under a Home / Academic License or Commercial License. This functionality had to be added to JavaScript for flexibility (read from file, extract data, reformat, etc)....
Admin
Site Admin
 
Posts: 2972
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to prefix with the EML file's Date header field?

Postby chrisjj » Wed Jul 09, 2025 12:05 pm

Admin wrote:JavaScript in BRU is available under a Home / Academic License or Commercial License.


Thanks. I guess Help "A commercial license for Bulk Rename Utility is required to use Javascript Renaming." is in error? I just now tested and found this feature working in my non-commercial-license installation.

Admin wrote:This functionality had to be added to JavaScript for flexibility (read from file, extract data, reformat, etc)....


Sorry if I implied I didn't think JS was a good place for it. I was thinking only that it wouldn't be if JS was restricted as advertised.

Any timescale for release?
chrisjj
 
Posts: 37
Joined: Wed Mar 30, 2011 5:26 pm

Re: How to prefix with the EML file's Date header field?

Postby chrisjj » Wed Jul 09, 2025 12:21 pm

PS Also:

Web: "For home use or academic use in schools and universities, home/academic licenses are available that will unlock all of the features of Bulk Rename Utility, including Javascript renaming." https://www.bulkrenameutility.co.uk/Buy.php?from=bru#ha
chrisjj
 
Posts: 37
Joined: Wed Mar 30, 2011 5:26 pm

Re: How to prefix with the EML file's Date header field?

Postby Admin » Thu Jul 10, 2025 2:26 am

Released in the next few hours I believe
Admin
Site Admin
 
Posts: 2972
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to prefix with the EML file's Date header field?

Postby Admin » Thu Jul 10, 2025 6:10 am

Hi, it's released here:

viewtopic.php?f=1&t=7110

To prefix the file name with the message date from the EML file header (converted to local time zone), use this javascript:

Code: Select all
// Example: if name is "invoice.eml", after running the script newName becomes something like "2025-07-08_15-30-00-invoice"
// 1) Read the "Date:" header line (case-insensitive)
var rawDateLine = fileMatch('^Date:\\s*.*', 'i');
// 2) Extract the substring after the first colon and trim whitespace
var dateValue = rawDateLine ? rawDateLine.substring(rawDateLine.indexOf(':') + 1).trim() : null;
// 3) Parse into a JavaScript Date (local time)
var msgDate = dateValue ? new Date(dateValue) : null;
// 4) Format as "YYYY-MM-DD_HH-mm-ss"
var dateStr = msgDate ? formatDateTime(msgDate, 'YYYY-MM-DD_HH-mm-ss') : '';
// 5) Prefix the original name (without extension) with the formatted date, separated by a dash
newName = dateStr ? dateStr + '-' + name : name;
Admin
Site Admin
 
Posts: 2972
Joined: Tue Mar 08, 2005 8:39 pm

Next

Return to BRU Support