Move all files not in a directory into a subdirectory named for each given file

Hi Everyone!

Looking for some help with a script that will take all files in any given root folder (which are not already in a folder) and put them into separate folders with the name of each given file.

Any ideas?

Thank you!

for x in `ls`; do if [ ! -e /path/to/subdirectory/$x ]; then mv $x /path/to/subdirectory/; fi; done