๐
Convert ASCIDOC to DOCX
On this page
sh
#!/bin/bashINPUT_EXTENSION=adocOUTPUT_EXTENSION=docx# for multiple extensions# find . -type f -name "*.img" -o -name "*.bin" -o -name "*.txt"`;for fullpath in $(find . -name "*.$INPUT_EXTENSION" -type f); do# Strip longest match of */ from startfilename="${fullpath##*/}"# Substring from 0 thru pos of filenamedir="${fullpath:0:${#fullpath}-${#filename}}"# Strip shortest match of . plus at least one non-dot char from endbase="${filename%.[^.]*}"# Substring from len of base thru endext="${filename:${#base}+1}"# If we have an extension and no base, it's really the baseif [[ -z "$base" && -n "$ext" ]]; thenbase=".$ext"ext=""fi# echo -e "$fullpath:\n\tdir = \"$dir\"\n\tbase = \"$base\"\n\text = \"$ext\""INPUT_FILE_PATH=$dir$baseasciidoctor --backend docbook --out-file - $INPUT_FILE_PATH.$INPUT_EXTENSION |pandoc --from docbook --to $OUTPUT_EXTENSION --output $INPUT_FILE_PATH.$OUTPUT_EXTENSIONecho "Convert $INPUT_FILE_PATH.$ext to INPUT_FILE_PATH.$OUTPUT_EXTENSION sussfully"done