Demo entry 5924327

Output

   

Submitted by anonymous on Sep 04, 2016 at 13:51
Language: Bash. Code size: 579 Bytes.

which pandoc > /dev/null
rc=$?
if [[ $rc != 0 ]]; then
  echo "Please install pandoc."
  exit 9
fi

if [ -z "$1" ]; then
  echo "Usage:"
  echo ""
  echo "  docx_to_md.sh [filename-no-extension]"
  exit 13
fi

if [ ! -f "$1.docx" ]; then
  echo "No file '$1.docx'"
  exit 11
fi

#Create Folders with name from file.
mkdir -p "$1"

#Change directory. Create files from docx to markdown and Mediafiles.
cd "$1"
pandoc -f docx -t markdown --extract-media="." -o $1 "../$1.docx"

#Change directory, delete .odt and .docx files.
cd ..
rm $1.odt
rm $1.docx

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).