#for file in posts/*.html stories/*.html; do dir=`dirname $file`; base=`basename $file .html`; echo pandoc -f html -t rst -o $dir/$base.rst $file; done

#for file in *.new; do pandoc -t html $file | pandoc -f html -t markdown - -o $file.md; done

EXT=wordpress.new
for file in */*.$EXT ;
do
  echo >&2 "Processing $file"
  dir=`dirname $file`;
  base=`basename $file .$EXT`;
  #pandoc $file | sed -e 's;<code> *$;<pre><code>;g' -e 's;^ *</code>;</code></pre>;g' | pandoc -f html -t markdown -o $dir/$base.md ;
  #pandoc $file | sed -e 's;<code>;<pre><code>;g' -e 's;</code>;</code></pre>;g' -e 's;<pre><code>\(.*\)</code></pre>;<code>\1</code>;g' | pandoc -f html -t markdown -o $dir/$base.md ;
  #sed -e 's;<code> *$;~~~;g' -e 's;^ *</code>;~~~;g' -e 's;<!-- *more *-->;<!-- TEASER_END -->;' < $file > $dir/$base.md
  sed -e '/<code> *$/,/^ *<\/code>/s/^/    /' -e 's;<blockquote><code> *$;;' -e 's;^ *</code></blockquote>;;' -e 's;<code> *$;;' -e 's;^ *</code>;;' -e 's;<!-- *more *-->;<!-- TEASER_END -->;' < $file > $dir/$base.md
done

Source