Skip to content

Instantly share code, notes, and snippets.

@vyder
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save vyder/82986c53021dff06e033 to your computer and use it in GitHub Desktop.

Select an option

Save vyder/82986c53021dff06e033 to your computer and use it in GitHub Desktop.
Octopress - :mass_edit rake task
editor = "iA Writer" # Editor to open markdown posts with
# usage rake mass_edit["category-name"]
desc "Edit all posts with the given category"
task :mass_edit, :category do |t, args|
args.with_defaults(:category => nil)
posts = Dir.glob("#{source_dir}/#{posts_dir}/*.*")
if :category.nil?
puts "No posts found with that category"
else
posts.each do |post|
puts "Iterating through #{post}..."
post_data = %x( cat #{post} )
if post_data.match(/categories: #{args.category}/)
system "open -a '#{editor}' #{post} &"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment