我正在使用 Pandoc 将 Markdown 转换为 .docx - 如何从生成的文件名中删除 .md?
I'm using Pandoc to convert Markdown to .docx - how do I remove the .md from the resulting filename?
我一直在 MacOS (OSX) 上的 Automator 中成功使用 shell 脚本,但我的方法在生成的文件名中保留了“.md”扩展名。
例如,如果我输入文件 myfile.md
,则输出为 myfile.md.docx
这是我的脚本:
for f in "$@"
do
if [[ "$f" = *.md ]]; then
/Users/myname/opt/anaconda3/bin/pandoc -o "${f%}.docx" -f markdown -t docx $f && open "${f%}.docx"
fi
done
谁能帮我完成这最后一步?
使用-o "${f%.*}.docx"
删除原来的扩展。
我一直在 MacOS (OSX) 上的 Automator 中成功使用 shell 脚本,但我的方法在生成的文件名中保留了“.md”扩展名。
例如,如果我输入文件 myfile.md
,则输出为 myfile.md.docx
这是我的脚本:
for f in "$@"
do
if [[ "$f" = *.md ]]; then
/Users/myname/opt/anaconda3/bin/pandoc -o "${f%}.docx" -f markdown -t docx $f && open "${f%}.docx"
fi
done
谁能帮我完成这最后一步?
使用-o "${f%.*}.docx"
删除原来的扩展。