在bash脚本中批量转换rst2html

时间:2014-04-17 07:34:10

标签: bash restructuredtext

对于bash编码器来说可能是一个简单的问题,但我无法弄清楚这个问题。 我在多个文件夹和子文件夹中有多个.rst文件。

enter image description here

如何创建一个脚本来转换html中的所有.rst文件(使用rst2html命令)并创建保留原始结构的新文件夹和子文件夹?

1 个答案:

答案 0 :(得分:0)

您可以先复制没有文件的整个层次结构(取自此link):

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

然后将每个.rst文件转换为.html并将其放在dest目录

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

[不是处理命令查找结果的最佳方式,但它有效:)]