diff --git a/convert_markdown.py b/convert_markdown.py new file mode 100644 index 0000000..30df71b --- /dev/null +++ b/convert_markdown.py @@ -0,0 +1,23 @@ +from os import listdir +from os.path import isfile, join +import os +import sys +import subprocess + +# argv[1] - wiki files directory + +if len(sys.argv) < 2: + print("Argument missing. Usage: python3 moin_convert.py ") +else: + path = sys.argv[1] + if os.path.exists(path): + files = [ f for f in listdir(path) if isfile(join(path, f)) ] + for filename in files: + name, file_extension = os.path.splitext(filename) + if file_extension == ".txt": + print("Converting %s/%s" % (path, filename)) + options = ['pandoc','-f','mediawiki','-t','markdown','-s',join(path,filename),'-o',join(path,name + ".md")] + subprocess.call(options) + else: + print("Error: the path specified is invalid") +