Skip to content

Instantly share code, notes, and snippets.

Forked from hugorodgerbrown/
Last active August 25, 2018 12:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Shell script for converting a batch of files using pandoc. This script will take two arguments: source extension, and target extension. pandoc will attempt to guess the formats.
# This script was created to convert a directory full
# of files into a different format. It uses pandoc to do the conversion.
# 1. Install pandoc from
# 2. Copy this script into the directory containing the files
# 3. Ensure that the script has execute permissions: chmod +x
# 4. Run the script
# By default this will keep the original file
# Usage: <source_extension> <target_extension>
# eg. rtf md
# $1 = extension of source files
# $2 = extension of target files
echo "-- Converting $source_ext to $target_ext in `pwd`"
for source_filename in $source_files
# extension="${f##*.}"
echo " - $source_filename"
echo " + $target_filename"
pandoc -s -o "$target_filename" "$source_filename"
# uncomment this line to delete the source file.
# rm $source_filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment