-
-
Save willwade/a719f1db4ac0f31199e4f7d75435a4e2 to your computer and use it in GitHub Desktop.
Batch convert files in a folder with Pandoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/ruby | |
# Change the file extensions below with what you are converting from and to | |
extFrom = '.html' | |
extTo = '.md' | |
files = Dir.glob("*#{extFrom}") | |
name = '' | |
base = '' | |
files.each do |file| | |
if File.exists?(file.strip) | |
f = File.open(file.strip, encoding: 'UTF-8') | |
name = File.basename(file) | |
base = File.basename(file).gsub(/#{extFrom}/, '') | |
command = "pandoc " + "#{name}" + " -o " + "#{base}" + "#{extTo}" | |
%x{#{command}} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment