Skip to content

Instantly share code, notes, and snippets.

@gboone
Last active July 22, 2016 00:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gboone/cd1b01c8501759418a5fd64f9b33072d to your computer and use it in GitHub Desktop.
Save gboone/cd1b01c8501759418a5fd64f9b33072d to your computer and use it in GitHub Desktop.
# Strips the body out of a document. Quick and dirty, assumes ARGV is a real directory with markdown or YAML files in it.
# I hard coded the directory and am not really a rubyist so there's a chance I screwed up this ARGV thing.
#!/usr/bin/env ruby
require 'yaml'
files = Dir.glob("#{ARGV[0]}/*")
for file in files
yaml = YAML.load(File.read(file))
File.open(file, 'w') { |f|
f.write(yaml.to_yaml + "---")
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment