Skip to content

Instantly share code, notes, and snippets.

@rvente
Created April 25, 2017 02:33
Show Gist options
  • Save rvente/fcaa3e50ee88bc9f3b5b39d822937dc8 to your computer and use it in GitHub Desktop.
Save rvente/fcaa3e50ee88bc9f3b5b39d822937dc8 to your computer and use it in GitHub Desktop.
This removes unwanted characters from the filename of docx files, then uses w2m to convert it all to markdown, and prepones the needed YAML header also. This is for mass conversions of the files needed. It should work on any bash system with w2m installed.
for run in {1..10} ; do
for file in *.docx ; do
mv "${file}" "${file// _/ }"
mv "${file}" "${file/_}"
mv "${file}" "${file// }"
mv "${file}" "${file//,}"
done
done
for file in *.docx ; do
echo "---
title: ""
categories:
- features
- news
- entertainment
- sports
- opinion
author:
---
" > "${file%%}.md"
done
for file in *.docx ; do
w2m "${file}" >> "${file%%}.md"
done
for md in *.md ; do
mv "${md}" 2017-11-15-${md%%}
done
for file in *.md ; do
mv "${file}" "${file/.docx}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment