How to work with attributes from Hazel in a js script

I do not really understand how passing in attributes into a javascript works.
I want to rename my file via regex, hence I am using javascript to do the complex renaming for me.
I want to import the name of the file as a variable, and export the name in the newName variable.
This is what it looks like now:
https://dl.dropboxusercontent.com/u/81328/hazel_js.png
This is my script:
What am I doing wrong?
Do I use the correct names for the input and output variables?
I want to rename my file via regex, hence I am using javascript to do the complex renaming for me.
I want to import the name of the file as a variable, and export the name in the newName variable.
This is what it looks like now:
https://dl.dropboxusercontent.com/u/81328/hazel_js.png
This is my script:
- Code: Select all
// Get the first entry of the inputAttributes
var name = inputAttributes[0];
// Set up regex queries
var dateQuery = /_(\d\d)\.(\d\d)\.(\d\d\d\d)_/g,
numberQuery = /Nr\.(\d\d\d)/g
// Regex work
var date = dateQuery.exec(name),
number = numberQuery.exec(name)[1];
// Define string variables
var day = date[1],
month = date[2],
year = date[3];
// Create output string and put it in an array, named hazelOutputAttributes
var hazelOutputAttributes = [year+'-'+number+' Kontoauszug '+day+'-'+month+'-'+year];
return true;
What am I doing wrong?
Do I use the correct names for the input and output variables?