Last active
August 29, 2015 13:57
-
-
Save fatbigbright/9887111 to your computer and use it in GitHub Desktop.
遍历一个目录的所有png图片文件,按照特定格式将它们列入一个markdown文件中。在windows+ruby1.8.7下测试通过。作为PSP《战律星云》汉化项目的命令行工具。
This file contains hidden or 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
def outputImage(directory, target) | |
File.open(target, 'w') do |t| | |
Dir.foreach(directory) do |file| | |
puts file | |
if File.extname(file) == ".png" | |
t.puts "\#\##{file}" | |
t.puts "\!\[#{file}\]\(.\\img\\#{file}\)" | |
t.puts | |
end | |
end | |
end | |
end | |
outputImage(ARGV[0], ARGV[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
不写最后一句第14行的调用,只有个函数的话,运行是没有任何结果的……