0

maybe a simple question for bash coders, but I'm not able to figure out this issue. I have multiple .rst files in multiple folders and sub-folders.

enter image description here

How can I create a script that converts all the .rst files in html (with the rst2html command) and creates new folder and sub-folders keeping the original structure?

09stephenb
  • 9,358
  • 15
  • 53
  • 91
matteo
  • 4,683
  • 9
  • 41
  • 77

1 Answers1

0

You can first copy the entire hierarchy without the files (taken from this link):

find /path/to/source -type d | cpio -pd /path/to/dest/

Then take every .rst file and convert it to .html with placing it in the dest directory

cd /path/to/source
find . -type f -name "*.rst" | while read f; do rst2html $f /path/to/dest/$f; done

[ Not the best manner to treat the result of command find, but it works :) ]

Bentoy13
  • 4,886
  • 1
  • 20
  • 33