You can simplify your request:
There is zero relevance of 'first', 'second', etc. here. It is simply enough to say "select some files and put each of them in a directory named according to the file.
This is not something that Automator can do, per se. Automator is almost useless when it comes to looping and logic flows - it's very linear.
You can do this via AppleScript, and that AppleScript can be embedded in an Automator workflow, so you can get there, but it is not as simple as dragging Automator Actions into a sequence.
Here's a simple AppleScript that prompts for files and creates a series of folders, one per file.
Put this in an Automator 'Run AppleScript' action, or run it directly via Script Editor.app:
tell application "Finder"
set theFilesToMove to (choose file with multiple selections allowed)
repeat with eachFile in theFilesToMove
set theFolder to container of eachFile
set basename to my stripExtension(eachFile)
set newFolder to make new folder at theFolder with properties {name:basename}
move eachFile to newFolder
end repeat
end tell
on stripExtension(theFile)
-- there is a 'proper' way to do this via AppleScriptObjC
-- but here's a simple pure AppleScript method
tell application "Finder"
set fn to name of theFile
set ext to name extension of theFile
if ext is not "" then
set charsToStrip to 2 + (count ext)
set fn to characters 1 through -charsToStrip of fn as text
end if
end tell
return fn
end stripExtension
There are other approaches too, depending on how you want to trigger it. This script is based around the script prompting you to select the files, but you could also set it up via Services so you can Ctrl-click on files in the Finder and trigger the script. Your call.