Find all files (not directories) in the current directory (not subdirectories) that do not have a ".txt" extension and delete them.
find . -mindepth 1 -maxdepth 1 -type f ! -name "*.txt" -exec rm -f {} +