Create New folder from selected text

I am trying to speed up some filing work. I have a set of files and would like to catagorise them in to sub folders. e.g.
Payment Rent Jan.pdf
Payment Rent Feb.pdf
Payment Utility Gas Jan.pdf
Bank Statment Personal Jan.pdf

In the above case I want 3 folders (Payment Rent, Payment Utility Gas & Bank Statement)
My idea is to select part of one of the files name, Then press a hot key so the selection is used to create a folder with that name. Then copy all matching files in to that folder.

I don't know how many of the words in the filename I will need, so I am guessing I will have to interact with the script some how. i.e. batch processing is not possible.
Currently I can do this manually by selecting the file, copy the text I want to use, shift cmd N to create a new folder, and paste the clipboard to the folder name hit enter. Then manually copy the required files in to the new folder.

I have played with trying to record this in KM but I do not seem to be able to replay the scripts.

Any one any ideas how I can go about his?

Let’s see.

1st you select a file in Finder window

2nd you hit enter, then select a part of the filename

3rd you press the hotkey for the KMMacro

Then KM can copy the text you select, use it to make a new folder.

When you select the file, KM also get the current finder path as working folder.

Before make the new folder, KM need to check if the folder name has been used.

Then KM search the files in the current working folder, if the file name contains the text you select before. Then KM will move the file to the new folder.

If this is what you want, you can test the KMMacro below to see if it helps. (Please backup files before test)
ANSWER create folder from filename then move file to that folder v0_Backup_20200324_1748_v0.kmmacros (18.4 KB)

Hi thanks for the macro.
however this does not seem to work. at least on my machine.
I get a notification saying:

macro cancelled: Action timed out exceeded " ANSWER create folder from filename then move file to that folder v0" cancelled (while executing copy)

HMM! Please see the screenshot:
Screen Shot 2020-03-24 at 19.06.47
I use these files to test this macro. Works Great.
You need to press hotkey after you select the text.
My MacOS is 10.12.6. Cannot believe it doesn't work on other machine.