you can just use
ls > filenames.txt
(usually, start a shell by using "Terminal", or "shell", or "Bash".) You may need to use cd to go to that folder first, or you can ls ~/docs > filenames.txt
cd
ls ~/docs > filenames.txt
If only names of regular files immediately contained within a directory (assume it's ~/dirs) are needed, you can do
~/dirs
find ~/docs -type f -maxdepth 1 > filenames.txt