Batch processing pandoc conversions
I made a bash script that would not work recursively, perhaps you could adapt it to your needs:
#!/bin/bash
newFileSuffix=md # we will make all files into .md
for file in $(ls ~/Sites/filesToMd );
do
filename=${file%.html} # remove suffix
newname=$filename.$newFileSuffix # make the new filename
# echo "$newname" # uncomment this line to test for your directory, before you break things
pandoc ~/Sites/filesToMd/$file -o $newname # perform pandoc operation on the file,
# --output to newname
done
# pandoc Catharsis.html -o test
You can apply any command across the files in a directory tree using find
:
find . -name \*.md -type f -exec pandoc -o {}.txt {} \;
would run pandoc
on all files with a .md
suffix, creating a file with a .md.txt
suffix. (You will need a wrapper script if you want to get a .txt
suffix without the .md
, or do ugly things with subshell invocations.) {}
in any word from -exec
to the terminating \;
will be replaced by the filename.