对子文件夹中的所有 html 个文件迭代 运行 inscript 命令行工具
Iterate run inscript command line tool over all html files in subfolders
我想将大量 html 文件转换为 txt 文件。我已经从 github 下载了 inscript 命令行工具,但我正在努力将它应用到位于子目录中的所有 html 文件,然后将这些文件作为文本文件保存在 html 个文件位于。
我试过:
for f in ./ do inscript.py -o test.txt done
以下应该有效:
for d in ./**/*/; do
pushd "$d"
for f in *.html(N); do
out=test-${f%.html}.txt
inscript.py -o "$out" "$f"
done
popd
done
模式.**/*/
将递归匹配当前目录及其所有子目录。 pushd
会切换到一个目录,但要记住当前的工作目录。 inscript.py
做它的事情,然后 popd
returns 到原始工作目录,以便 d
的下一个值继续有效
相对目录。
更改工作目录不是绝对必要的;它只是简化了涉及的文件路径,因为您专注于文件名而忽略路径的其余部分。
我想将大量 html 文件转换为 txt 文件。我已经从 github 下载了 inscript 命令行工具,但我正在努力将它应用到位于子目录中的所有 html 文件,然后将这些文件作为文本文件保存在 html 个文件位于。
我试过:
for f in ./ do inscript.py -o test.txt done
以下应该有效:
for d in ./**/*/; do
pushd "$d"
for f in *.html(N); do
out=test-${f%.html}.txt
inscript.py -o "$out" "$f"
done
popd
done
模式.**/*/
将递归匹配当前目录及其所有子目录。 pushd
会切换到一个目录,但要记住当前的工作目录。 inscript.py
做它的事情,然后 popd
returns 到原始工作目录,以便 d
的下一个值继续有效
相对目录。
更改工作目录不是绝对必要的;它只是简化了涉及的文件路径,因为您专注于文件名而忽略路径的其余部分。