Forum

 
Current User: Guest Login Register
Please consider registering


Register? | Lost Your Password?

Using regular expression backreference in move destination?

Add a New Topic Reply to Post
UserPost

12:09 am
March 26, 2010


maf

Member

posts 5

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

9:14 am
March 26, 2010


rkent

Admin

posts 140

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.

10:24 am
March 26, 2010


maf

Member

posts 5

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.

10:31 am
March 26, 2010


rkent

Admin

posts 140

"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.

10:45 am
March 26, 2010


maf

Member

posts 5

> 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?

11:34 am
March 26, 2010


rkent

Admin

posts 140

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.

11:31 pm
March 26, 2010


maf

Member

posts 5

> 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?

12:53 am
March 27, 2010


rkent

Admin

posts 140

"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.

1:19 am
March 27, 2010


maf

Member

posts 5

> 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.

Reply to Post

Reply to Topic:
Using regular expression backreference in move destination?

Guest Name (Required):

Guest Email (Required):

NOTE: New Posts are subject to administrator approval before being displayed

Smileys
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell
Post New Reply

Guest URL (required)

Math Required!
What is the sum of:
7 + 12