import os files = os.listdir() for f in files: if f.endswith('.html'): name = f.split('.')[0] cmd = "html2md -i {0} -o {1}.md".format(f, name) print(cmd)