Forum

Share

Please consider registering
guest

Log In RegisterMembers
Or log in with

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Using regular expression backreference in move destination?
March 26, 2010
12:09 am
Member
Forum Posts: 5
Member Since:
March 25, 2010
Offline

Hello,

It would be great for me if I could use a backreference to some part of a filter's regular expression when specifying the destination folder for moving the message. I.e., using Posix-like regular expression syntax, I would like to specify something like "Bill no \([0-9]\)" for the message subject and move matching messages to a folder containing "Local Folders\/Accounting\/\1" (not sure about the folder separators here).

Any chance this functionality could be added to FiltaQuilla (or achieved by any other Addon?

Cheers, Malte

Share
March 26, 2010
9:14 am
Admin
Forum Posts: 323
Member Since:
July 12, 2008
Offline

The exact request that you are making is quite specific, and therefore likely to be of interest to very few users. I am not aware of any addons that have this capability, not do I see it as a likely addition of FiltaQuilla.

I can think of lots of ways that you could achieve similar results, however. There is of course the obvious adding 10 filters to accomplish your example. But as another more elegant solution, use the javascript search capability, but when you find the match modify the message in the search javascript. For example, add the tag "Accounting1" that you generate programmatically in the search javascript, and then use virtual folders (based on tags) rather than real folders to show Accounting1 contents.

One of my high priorities for FiltaQuilla for the future is to add a javascript custom action, like there is currently a javascript search term. Then you could also do the same things in a filter action, which would include a move, if you knew what you were doing.

Share
March 26, 2010
10:24 am
Member
Forum Posts: 5
Member Since:
March 25, 2010
Offline

Unfortenately, the number of destination folder is large while their names are not known beforehand. So creating the "right" rules in advance or using a predefined set of tags doesn't work for me.

Your Javascript custom action does sound good, though. Would FiltaQuilla's Javascript search term allow one to use regular expressions in the search and could I pass values (e.g. matches) to the Javascript action? I guess, I'd also need some Thunderbird scripting capability, e.g. to create folders based on matches found by the search term.

Share
March 26, 2010
10:31 am
Admin
Forum Posts: 323
Member Since:
July 12, 2008
Offline

"Would FiltaQuilla's Javascript search term allow one to use regular expressions in the search"

Sure, why not?

"could I pass values (e.g. matches) to the Javascript action"

You can set arbitrary properties on the message in the search, like message.setStringProperty("accountName", regexResult). Then on the action, you could read this value to determine the folder name.

Share
March 26, 2010
10:45 am
Member
Forum Posts: 5
Member Since:
March 25, 2010
Offline

> Sure, why not?

Oh, just asking. I simply havn't used Javascript (or FiltaQuilla) before.

> You can set arbitrary properties on the message in the search[...]

Great. So, do you already have any timeline for the inclusion of Javascript actions in FiltaQuilla?

And how about creating folders on the fly?

Share
March 26, 2010
11:34 am
Admin
Forum Posts: 323
Member Since:
July 12, 2008
Offline

A timeline?  Hmmm, would you accept Real Soon Now? If I had to guess I would say I will probably do it in the next 4 weeks, and definately when I update FiltaQuilla to support any new TB 3.1 features, but that is a guess, not a commitment.

Creating folders on the fly is possible, but as the actions required get more complex, at some point it makes more sense to write your own extension rather than simply inject some javascript into mine.

Share
March 26, 2010
11:31 pm
Member
Forum Posts: 5
Member Since:
March 25, 2010
Offline

> Hmmm, would you accept Real Soon Now?

Sure. So I'll install FiltaQuilla and watch for the next update.

> at some point it makes more sense to write your own extension

Well, I have not used JavaScript before, except for tweaking an existing Greasemonkey script. So writing my own extension will probably take me much longer than adapting yours.

Could I check for the existence of a folder or create a folder from within your JavaScript action – using JavaScript, I guess?

Share
March 27, 2010
12:53 am
Admin
Forum Posts: 323
Member Since:
July 12, 2008
Offline

"Could I check for the existence of a folder or create a folder from within your JavaScript action – using JavaScript, I guess?"

Yes you can, at least in theory. It would be much more challenging with IMAP than with local folders, due to the async nature of IMAP. If you're not experienced in the Mozilla mailnews coding environment, you would need a lot of hand holding though. The documentation is spotty.

Share
March 27, 2010
1:19 am
Member
Forum Posts: 5
Member Since:
March 25, 2010
Offline

> Yes you can, at least in theory. It would be much more challenging with IMAP than with local folders

Luckily, its only local folders I have to deal with. I'll look for some assistance in this and other forums when the need arises Wink.

Share
Forum Timezone: UTC -8

Most Users Ever Online: 18

Currently Online:
8 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

bobkatz: 8

BigMike: 8

t2m: 7

zabolyx: 7

taa: 6

onlyme: 6

Member Stats:

Guest Posters: 130

Members: 565

Moderators: 1

Admins: 1

Forum Stats:

Groups: 1

Forums: 7

Topics: 231

Posts: 802

Moderators: rkent (323)

Administrators: rkent (323)