Since you asked (or, at least, I inferred you were asking for) a Folder Action, you should save this script in your Folder Action Scripts folder in ~/Library/Scripts/
Then, find the folder that you want it to watch, ctrl-click the folder and choose Folder Actions Setup from the Services menu.
From here you can see the folders that have Actions assigned (it may be a very short list). Select your folder and then click the + button below the list of active scripts on the right-hand-side. You should see a list of installed Folder Actions Scripts, including the one you just saved. Select it, and you're done. Dropping a file into this folder should now trigger the script.
A thought did just occur to me, though, that the script might need a little more sanity checking. Since the script creates a new folder to move the file into, the script could re-fire as the new folder looks like a new item that needs to be filtered/moved. An additional check to make sure the dropped file is, indeed, a file that needs to get moved would be a good idea. This updated version ensures the script only triggers on documents, not folders:
on adding folder items totheFolderafter receivingtheNewItems
repeat with eachItem in theNewItems
tell application "Finder"
if class of eachItem is document file then
set theBaseName to my getBaseNameOf(eachItem)
set theNewFolder to makenewfolderattheFolderwith properties {name:theBaseName}
moveeachItemtotheNewFolder
end if
end tell
end repeat
end adding folder items to
on getBaseNameOf(thisItem)
tell application "Finder"
set ext to name extension of thisItem
set extLength to number of characters in ext
set n to characters 1 through -(extLength + 2) of (get name of thisItem) as text
end tell
return n
end getBaseNameOf