Here's what I want bash to do, first in pseudocode, then in bash as far as I've gotten, then the error:
"What I want" pseudocode
If a file is saved in the "Cover Letters" directory with a filename ending in "md":
run a Bash command like:
pandoc [FILENAME] -o [FILENAME].replace(".md",".pdf") -s -S
What I've Got So Far
:autocmd BufWritePost ~/Dropbox/Professional/Covers/*.md pandoc % -o ${%/md/pdf} -s -S
This code correctly identifies when a "md" file is being saved in the Dropbox folder, and then runs a command incorporating the filename. However, the command errors out with:
"test.md" 1L, 6C written
:!pandoc test.md -o ${test.md/md/pdf} -s -S
/bin/bash: ${test.md/md/pdf}: bad substitution
shell returned 1
What's wrong with my substitution? I feel like I'm so close...
Edit: current version:
autocmd BufWritePost ~/Dropbox/Professional/Covers/*.md #!star='~/Dropbox/Professional/Covers/'% && fin=${star/md/pdf} && p andoc star -o fin -s -S