【问题标题】:batch rst2html conversion in a bash script在 bash 脚本中批量转换 rst2html
【发布时间】:2014-04-17 07:34:10
【问题描述】:

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

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

【问题讨论】:

  • rst2html 命令取自哪里?
  • 我刚刚用apt-get install rst2html下载了它
  • 那么你是在UNIX环境下?
  • 哦,对不起.. 是的,使用 debian..

标签: bash restructuredtext


【解决方案1】:

您可以先复制没有文件的整个层次结构(取自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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-10
    • 2011-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多