hi there, 1st post and new to Hazel. I'm doing Ok with the rules, Hazel is awesome and the functionality described in this thread is exactly what I need.
I never worked with scripts before so i'm a little lost here.
I pasted the script in Hazel action "Run shell script" and modified two things too try and match my needs as seen below (bold). (note: Data de Vencimento means Closing date in Portuguese):
path=`dirname "$1"`
/usr/bin/mdimport -d2 "$1" >& "$path"/"_extract.txt"
x=`egrep -o '
Data de Vencimento ..\/..\/....' "$path"/"_extract.txt" | awk '{print $3}'`
rm -rf "$path"/"_extract.txt"
d=`echo $x | awk -F'/' '{print $1}'`
m=`echo $x | awk -F'/' '{print $2}'`
y=`echo $x | awk -F'/' '{print $3}' | awk '{print "20"$1}'`
touch -t "$y$m$d"0000 "$1"
mv "$1" "$path"/"$m-$d.pdf"
exit 0
I modified the date format to use year with 4 digits and changed day - month order to match my date format.
The result was a filename with a dash and the extension, like this: "-.pdf"
The file I'm trying to extract the date has the name "Data de Vencimento" above the date, see image attached.

How can I make it work?
Thanks and appreciate your help!!!