[tex4ht] make output of tex4ht go to sub-folder without leaving temporary and intermediate files in the current folder?

Nasser M. Abbasi nma at 12000.org
Sun Feb 3 20:49:46 CET 2013

Is there a way to tell tex4ht to generate all its output
into a sub-folder from where the latex file is ?

Suppose I have this tree

----------------
foo.tex
a.png
-----------------

Where inside foo.tex there is includegraphics to a.png

--- foo.tex ----------
\documentclass{article}%
\usepackage{graphics}
\begin{document}
\includegraphics{a.png}
\end{document}
-------------------------

Now I want to build HTML file from foo.tex but want all
the intermediate and any auxiliary files tex4ht generated
(including any html files) to go to a sub-folder, say A/, so
I'd _LIKE_ to end up with

-----------------------------
foo.tex
a.png
+
|
A/---- foo.htm
foo.xref
foo.tmp
etc.....
a.png

--------------------------------

I use the option

htlatex foo.tex "" "" -dA/

But it still leaves many many files in the same folder, and
it only copies foo.htm and a.png to the sub-folder.

I have to go clean all that each time. I want the parent
folder to remain the same as before.

Is there a way to do that?

thanks
--Nasser