There are two basic approaches that you could use.
One is the real recursive one. The script would need to process the files into a dir one by one. The basic scheme would be:
Code:
if [ "$1" == "" ]; then
dir=$PWD
else
dir="$1"
fi
for file in "$dir"
do
if [ -d file ]; then
$0 "$dir" # launches the script again on the next dir
else if [ ! "${file/.html/}" == "${file}" ]; then
# if the filename without ".html" is not the same than the filename
# then the file is an html file, there are many other ways to check this
# Here you must insert the commands to convert $file to pdf
else
: # do nothing since it's not a dir, and it's not html either.
fi
done
That's just the basic idea and might not be perfect but it should put you on the right track if you really want to do this recursively.
The other way (usually simpler and probably much less intensive in ram usage) is to just use find, with -exec. Or better, use it to feed a while loop which brings you more possibilities. For example:
Code:
cd /whatever/dir/; find . -name \*.html | while read file; do html2pdf "$file" "${file/.html/.pdf}"; done
I have no idea if html2pdf is a real tool, and if it is I have no idea of the syntax. The above snippets are meant only as a rough example on how to implement this on a bourne compatible shell.