Page 1 of 2

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

PostPosted: Mon Mar 31, 2025 7:32 pm
by chrisjj
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.

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

PostPosted: Mon Mar 31, 2025 10:47 pm
by Admin
What does the Windows File Property -> Details tab show for the EML file? Bulk Rename will match that.

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

PostPosted: Mon Mar 31, 2025 11:02 pm
by chrisjj
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.

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

PostPosted: Tue Apr 01, 2025 5:21 am
by Admin
You can adapt the date with BRU javascript, can you send a sample file to support via email? thanks

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

PostPosted: Tue Apr 01, 2025 9:44 am
by chrisjj
Admin wrote:You can adapt the date with BRU javascript, can you send a sample file to support via email? thanks

Done. Thanks.

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

PostPosted: Thu Jul 03, 2025 11:59 am
by chrisjj
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.

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

PostPosted: Sun Jul 06, 2025 1:22 am
by Admin
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.

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

PostPosted: Sun Jul 06, 2025 10:49 am
by chrisjj
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?

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

PostPosted: Tue Jul 08, 2025 12:40 am
by Admin
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.

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

PostPosted: Tue Jul 08, 2025 11:26 am
by chrisjj
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?

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

PostPosted: Wed Jul 09, 2025 3:04 am
by Admin
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)....

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

PostPosted: Wed Jul 09, 2025 12:05 pm
by chrisjj
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?

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

PostPosted: Wed Jul 09, 2025 12:21 pm
by chrisjj
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

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

PostPosted: Thu Jul 10, 2025 2:26 am
by Admin
Released in the next few hours I believe

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

PostPosted: Thu Jul 10, 2025 6:10 am
by Admin
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;