Problems using Custom Attributes (Export)

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

The pictures are cropped in this forum, please right-click and open in a separate browser-window.

Hi,

I have serious problems getting along with custom export attributes. I just don't get how it works. I already searched the web, but basically the only helpful post I've found is this http://www.noodlesoft.com/forums/viewtopic.php?f=3&t=1587. I've used this as a tutorial.

Example workflow:
I want a file named 'test.txt' to be renamed in [date added][custom export attribute][name].txt:

Conditions:
1) Name is test
2) Kind is Text
3) Passes Apple Script (embedded script) -> Script should only return a custom attribute which is fixed to "02" for this example.

Action:
Rename with pattern: [date added][custom export attribute][name].txt

Image
Image

The problem is that returning the custom export attribute from Apple Script causes trouble. It seems that the return statement is wrong. I don't know if I'm doing it wrong or if this is a bug. The following error appears (also cf. the logfile at the end of this post):

Image

My question: What do I have to do in order to return a custom attribute from an Apple Script and to use it in my actions. Can someone give me an example, please?

Any help is appreciated - thanks!

---
I'm using Hazel 3.3.4 (Build 1232) on Yosemite.

Logfile entry:
2015-02-21 18:57:56.259 hazelworker[1647] Processing folder testfolder
2015-02-21 18:57:58.561 hazelworker[1647] [Error] Error during rule evaluation: Received error while trying to evaluate rule rename txt-file on file test.txt
2015-02-21 18:57:58.561 hazelworker[1647] Error while matching rule rename txt-file against file /Users/homefolder/Desktop/testfolder/test.txt: Invalid AppleScript return value: <NSAppleEventDescriptor: { 'usrf':[ 'utxt'("hazelExportTokens"), { 'usrf':[ 'utxt'("qwertz"), 'utxt'("02") ] } ] }>.
2015-02-21 18:57:58.561 hazelworker[1647] ###main load address: 0x10118d000
2015-02-21 18:57:58.561 hazelworker[1647] ###Noodle load address: 0x1012a3000
2015-02-21 18:57:58.561 hazelworker[1647] ###CK load address: 0x101266000
2015-02-21 18:57:58.561 hazelworker[1647] (
0 CoreFoundation 0x00007fff8c7e366c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8f80b76e objc_exception_throw + 43
2 hazelworker 0x00000001011bd2a7 hazelworker + 197287
3 Foundation 0x00007fff8eafc16a -[NSPredicateOperator performOperationUsingObject:andObject:] + 285
4 Foundation 0x00007fff8eafb872 -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] + 313
5 hazelworker 0x00000001011f3fb4 hazelworker + 421812
6 hazelworker 0x00000001011f40ac hazelworker + 422060
7 hazelworker 0x00000001011f2c99 hazelworker + 416921
8 hazelworker 0x00000001011fdc3f hazelworker + 461887
9 hazelworker 0x00000001011f1200 hazelworker + 410112
10 hazelworker 0x00000001011c55df hazelworker + 230879
11 hazelworker 0x00000001011945a6 hazelworker + 30118
12 hazelworker 0x0000000101195e12 hazelworker + 36370
13 hazelworker 0x0000000101197e42 hazelworker + 44610
14 libdyld.dylib 0x00007fff8db355c9 start + 1
)
2015-02-21 18:57:58.768 hazelworker[1647] Done processing folder testfolder
goethesfaust
 
Posts: 6
Joined: Sat Nov 09, 2013 3:34 pm

Re: Problems using Custom Attributes (Export) Mon Feb 23, 2015 12:08 pm • by Mr_Noodle
hazelExportTokens is the old one. You want to use hazelOutputAttributes now. Note that it's a list, not a record, and the order of values you return needs to match up with the list of attributes you specify in the UI.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Oh, I also noticed that you are using an AppleScript in a condition. In that case, you also need to return whether the file passes the script via the "hazelPassesScript" item in the record.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for your support! Now it works as expected :)

BTW, the correct code for my example is:

Code: Select all
return {hazelExportTokens:{"02"}, hazelPassesScript:true}
goethesfaust
 
Posts: 6
Joined: Sat Nov 09, 2013 3:34 pm


Return to Support