1 つのフォルダーに多数の html ファイルがあります。これらをマークダウンに変換する必要があります。これを 1 つずつ行う素晴らしい宝石がいくつか見つかりました。私の質問は...フォルダー内の各ファイルをループし、コマンドを実行してこれらを別のフォルダーのmdに変換するにはどうすればよいですか。
アップデート
#!/usr/bin/ruby
root = 'C:/Doc'
inDir = File.join(root, '/input')
outDir = File.join(root, '/output')
extension = nil
fileName = nil
Dir.foreach(inDir) do |file|
# Dir.foreach will always show current and parent directories
if file == '.' or item == '..' then
next
end
# makes sure the current iteration is not a sub directory
if not File.directory?(file) then
extension = File.extname(file)
fileName = File.basename(file, extension)
end
# strips off the last string if it contains a period
if fileName[fileName.length - 1] == "." then
fileName = fileName[0..-1]
end
# this is where I got stuck
reverse_markdown File.join(inDir, fileName, '.html') > File.join(outDir, fileName, '.md')