I am currently trying to batch convert a bunch of html files to txt files using html2txt inside a python virtual environment. My script as-is currently is the following:
#!/usr/bin/bash
NAME=""
source ~/pythonenvs/env_tomboyconversion/bin/activate
for i in $(ls *.html); do
NAME=$(basename -s .html $i)
html2text $i > "$NAME.txt"
done
deactivate
Whenever I run the script, I end up with with multiple empty text files where it's obvious the original filename was split on spaces. For example, if I have a file original file.html, it will result in original.txt and file.txt. The problem I'm having is I can't figure out where to apply quotes in order to keep filenames from being split on the spaces. I've tried the above, as well as putting the $i, around the $(basename -s .html $i) expression, and various combinations thereof, but the filenames keep getting split. How can I get the filenames to stop splitting on the spaces?