#1 2019-05-21 10:14

Zappozeppo
Member
Registered: 2019-05-20
Posts: 2

Meta Tag width limit setting

Hi,
I'm trying ReNamer to rename folders of EML files.
I found it wonderful.

It's easy to select Meta Tags, renaming files tipically with the sequence Date-Sender-Recipient-Subject but, as other software do, to avoid filename exceeding maximum file lenght, I need to set a maximum number of characters for each Meta Tag.
In other words, as example, inserting only first 80 characters of Email_Subject.
Is there some way to accomodate this?

Thank you in advance
ZZ

Offline

#2 2019-05-21 23:24

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: Meta Tag width limit setting

There are two methods to achieve this currently. They may not be the most user friendly methods, but they will do the job.

Method 1 - Regular Expressions

Encapsulate your meta tags in some kind of brackets or other delimiters, and then use Regular Expressions rule to trim the content between delimiters to a required maximum number of characters.

Expression: \[([^]]{0,5})[^]]*\]
Replace: $1

Example input: Hello [123456789] World [123]
Example output: Hello 12345 World 123

Hint: Change the 5 to 80 in the expression to keep up to 80 characters.

Method 2 - Pascal Script

Use Pascal Script rule to insert meta tags and to trim them to the required maximum number of characters.

var
  MetaTag: WideString;
begin
  MetaTag := CalculateMetaTag(FilePath, 'Hash_SHA1');
  FileName := WideCopy(MetaTag, 1, 10) + FileName;
end.

Hint: Change 10 to 80 in the script to keep up to 80 characters.

Offline

#3 2019-05-22 10:13

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Meta Tag width limit setting

Another workflow idea with standard tools, based on the usual data
your Meta Tags contains, perhaps this will fit for somebody reading this thread later:


- Add Date + Sender + Recipient
- Use one-or-more Replace Rule to shorten well know names: Replace "Zappozeppo" with "ZZ",
Replace "Question" by "Qeust" , Replace " - " by "-" and so on...
- Add Subject
- Use one-or-more Replace Rule to shorten well know phrases: Replace "As soon as possible" with "asap"
- Maybe use Strip and/or Clean Up Rules too
- At the end use Delete Rule: Pos. 160 until the End


Or add Date + Sender and next shorten with Delete Rule: Pos. 60 until the End
Next add Recipient and  shorten with Delete Rule: Pos. 90 until the End
Next add Subject and  shorten with Delete Rule: Pos. 200 until the End


Or add Subject first, then shorten it with Delete Rule: Pos. 80 until the End
Next add other Meta Tags, but now as Prefix!


There were also ideas to shorten double chars, like "Madonna" to "Madona"
or to replace "for" by 4 or such things.

All depending on the usual input and the wanted result.

You can save that as Preset for reuse the next time.


HTH?


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#4 2019-05-22 22:06

Zappozeppo
Member
Registered: 2019-05-20
Posts: 2

Re: Meta Tag width limit setting

Thank you all for the quick answers.
I finally decided to activate a Pascal routine, obtaining a simple, linear, perfectly configurable, single rule.
I know I could use a strip rule to eliminate unwanted characters, but I like a lot a single Pascal rule.
I only added a second CLEANUP rule to eliminate unwanted spaces, normalize unicode and prepare to sharepoint.
I will experiment Method 1 of  den4b
And the - progressive adding tags and deleting from nn character to the end – of Stefan is absolutely great.
Thanks to everybody.
ZZ


As a comment:
My purpose is not to reduce filename as possible, but to rename using the four tags people is used to search, along past mail big archives.
With this kind of renaming you can search mails with pre-indexing cataloguing software as Everything.
The limit in filename length (in the complete path of the file, really) is due to backup purposes if you use as destination a sharepoint / OneDrive for Business store.

Here is my code:

var
  MyDate: WideString;
  MySender: WideString;
  MyRecipient: WideString;
  MySubject: WideString;
  MyFinalName: WideString;
begin
  MyDate := CalculateMetaTag(filepath, 'Email_DateSent');
  MySender := CalculateMetaTag(filepath, 'Email_SendereMail');
  MyRecipient := CalculateMetaTag(filepath, 'Email_RecipienteMail');
  MySubject := CalculateMetaTag(filepath, 'Email_Subject');
  MySubject := WideCopy(MySubject,0,80);
  MyFinalName := MyDate + '-' + MySender + '-' + MyRecipient + '-' + MySubject;
  WideReplaceStr(MyFinalName, '\', '');
  WideReplaceStr(MyFinalName, '<', '');
  WideReplaceStr(MyFinalName, '>', '');
  WideReplaceStr(MyFinalName, '!', '');
  WideReplaceStr(MyFinalName, '?', '');
  WideReplaceStr(MyFinalName, '|', '');
  WideReplaceStr(MyFinalName, '#', '');
  WideReplaceStr(MyFinalName, '$', '');
  WideReplaceStr(MyFinalName, '%', '');
  WideReplaceStr(MyFinalName, '^', '');
  WideReplaceStr(MyFinalName, '&', '');
  WideReplaceStr(MyFinalName, '~', '');
  WideReplaceStr(MyFinalName, '`', '');
  WideReplaceStr(MyFinalName, '+', '');
  WideReplaceStr(MyFinalName, '=', '');
  WideReplaceStr(MyFinalName, '/', '');
  WideReplaceStr(MyFinalName, '*', '');
  WideReplaceStr(MyFinalName, ':', '');
  WideReplaceStr(MyFinalName, ';', '');
  FileName := MyFinalName + '.eml';
end.

Offline

Board footer

Powered by FluxBB