How to check for specific content of folder?

Hi,
I'm trying to create an action that checks the content of folders, and if it contains more than 4 files of a specific filetype/extension, then move the parent folder.
I tried to do it with a "If kind is folder then run applescript" and wrote a script that I thought would do it, but it throws an awful lot of errors in the console.
Anyone done this before?
Thanks!
I'm trying to create an action that checks the content of folders, and if it contains more than 4 files of a specific filetype/extension, then move the parent folder.
I tried to do it with a "If kind is folder then run applescript" and wrote a script that I thought would do it, but it throws an awful lot of errors in the console.
Anyone done this before?
Thanks!