embedding AppleScript for renaming subfolders

I am looking for a solution to the following problem:
filename on desktop is "Word1 Word2 Word3.txt"
I hope to use an embedded Applescript to create a subfolder with a name corresponding to the second word (i.e., Word2) of the original filename. Is this possible?
My initial thought is:
1. add a line to the Hazel rule to "Run AppleScript"
2. Specify the custom attributes imported (Name) and exported (subfolderName) by the embedded AppleScript.
3. set CurrentName to item 1 of inputAttributes
4. set folderName to second word of CurrentName
5. return {hazelOutputAttributes:{subfolderName}}
6. add a line to the Hazel rule to "Sort into subfolder" with the custom pattern "subfolderName"
I know there are steps missing here but not sure how to move forward with this automation.
filename on desktop is "Word1 Word2 Word3.txt"
I hope to use an embedded Applescript to create a subfolder with a name corresponding to the second word (i.e., Word2) of the original filename. Is this possible?
My initial thought is:
1. add a line to the Hazel rule to "Run AppleScript"
2. Specify the custom attributes imported (Name) and exported (subfolderName) by the embedded AppleScript.
3. set CurrentName to item 1 of inputAttributes
4. set folderName to second word of CurrentName
5. return {hazelOutputAttributes:{subfolderName}}
6. add a line to the Hazel rule to "Sort into subfolder" with the custom pattern "subfolderName"
I know there are steps missing here but not sure how to move forward with this automation.