Page 1 of 1

replace text doesn´t work with custom tokens

PostPosted: Thu Mar 14, 2013 6:11 am
by Graf_Wetter
Hi,

I have a custom token "Operator" generated by this simple Applescript:
Code: Select all
return {hazelExportTokens:{Operator:do shell script "whoami"}}


It gives the shortname of the current user, e.g. "jpreussmann"
Now I want this token to be added to the original name of the triggered file,
but not the whole name but only the first two letters.
So I tried the tokens option "replace text".

Image

The tokens value is added to the name but without the text replacement.

Any ideas ?

Thanks,
Joerg

Re: replace text doesn´t work with custom tokens

PostPosted: Fri Mar 15, 2013 12:48 pm
by Mr_Noodle
Not sure about why the text replacement isn't working but if you are hardcoding the name in there anyways, why use a script and export token? Also, it might be better to shorten the name in the script.

Re: replace text doesn´t work with custom tokens

PostPosted: Mon Mar 18, 2013 7:00 am
by Graf_Wetter
Take it as an example.
It seems that the text replacement for script-exported tokens doesn´t work in general.
Could you verify this an your systems ?

Re: replace text doesn´t work with custom tokens

PostPosted: Mon Mar 18, 2013 11:29 am
by a_freyer
CONFIRMED on my machine. Replacing text on modified token has no effect for me either. No log errors.

Re: replace text doesn´t work with custom tokens

PostPosted: Mon Mar 18, 2013 2:18 pm
by Mr_Noodle
I have some vague inkling that this may be by design though I don't recall what the reason was. I'll have to poke around in the code again to see if it comes back to me but for now, I think you should do any munging in the script itself.

Re: replace text doesn´t work with custom tokens

PostPosted: Mon Mar 18, 2013 3:14 pm
by a_freyer
You may know this already, but the appropriate replace script for you would be:

Code: Select all
return {hazelExportTokens:{Operator:do shell script "whoami | sed 's/originaltext/replacementtext/g'"}}

Re: replace text doesn´t work with custom tokens

PostPosted: Tue Mar 19, 2013 11:07 am
by Graf_Wetter
Text replacement for custom tokens within Hazel is not a must have, I found a lot of easy workarounds.
Your script could be one of them, thanks.
But I like to have Hazel processing as much as possible to reduce scripting to a minimum.
As for me Hazel is much easier to control than a script.
So it would be just nice if this broken text-replacement could be fixed.

Re: replace text doesn´t work with custom tokens

PostPosted: Tue Mar 19, 2013 1:12 pm
by Mr_Noodle
Unless I can remember why I did it this way, I'll probably end up changing it in a future release. I need to keep better notes...

Re: replace text doesn´t work with custom tokens

PostPosted: Thu Nov 20, 2014 12:10 am
by jimbo99
Please fix this feature, as it is much needed by me too. I have 3.3.1 and this issue still exists. (Otherwise an excellent product.)

Re: replace text doesn´t work with custom tokens

PostPosted: Thu Nov 20, 2014 11:09 am
by Mr_Noodle
This feature is fixed. If it's not working for you, please provide more details.

Re: replace text doesn´t work with custom tokens

PostPosted: Thu Dec 18, 2014 3:18 am
by jimbo99
this didn't work for me with 3.3.1, it didn't save the replace text settings.
HOWEVER, just updated to 3.3.3 and it now WORKS!

Thanks, a great product.