Skip to content

Instantly share code, notes, and snippets.

@fatbigbright
Last active August 29, 2015 13:57
Show Gist options
  • Save fatbigbright/9887111 to your computer and use it in GitHub Desktop.
Save fatbigbright/9887111 to your computer and use it in GitHub Desktop.
遍历一个目录的所有png图片文件,按照特定格式将它们列入一个markdown文件中。在windows+ruby1.8.7下测试通过。作为PSP《战律星云》汉化项目的命令行工具。
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])
@fatbigbright
Copy link
Author

不写最后一句第14行的调用,只有个函数的话,运行是没有任何结果的……

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment