YouAssuming we know that all files have the filename suffixes .html or .txt and that all directories have the suffix .directory, you can use:
for i in *.txt *.html
do
mv "$i" "${i%%.*}.directory/$i"
done
Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.