Created
June 11, 2014 15:18
-
-
Save craigeley/bf189da1de3c70753cea 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