Filing expenses into Australian financial years

The Australian financial year goes from 1 July through to 30 June. This makes it somewhat complicated to use Hazel to file into those years.
I noticed I could use an embedded AppleScript as a condition in Hazel and started fooling around.
The script is:
I also set up an output attribute on the embedded script called financialYear.
The script passes back the financial year to Hazel and then uses that to sort into subfolders with the form "FYXX"
I noticed I could use an embedded AppleScript as a condition in Hazel and started fooling around.
The script is:
- Code: Select all
set savedDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"-"}
tell application "Finder"
set filename to name of theFile
end tell
set expenseYear to (first text item of filename) as number
set expenseMonth to (second text item of filename) as number
-- Get the last two characters of the Year
set AppleScript's text item delimiters to savedDelimiters
set lastTwoCharactersOfYear to (characters 3 thru 4 of (expenseYear as text))
set financialYear to (lastTwoCharactersOfYear as text) as number
if expenseMonth ≥ 7 then
set financialYear to financialYear + 1
end if
set returnText to "FY" & financialYear
-- Note: the order of the hazelOutputAttributes list needs to match the order of the outputAttributes in Hazel
return {hazelOutputAttributes:{returnText}, hazelPassesScript:true}
I also set up an output attribute on the embedded script called financialYear.
The script passes back the financial year to Hazel and then uses that to sort into subfolders with the form "FYXX"