Last active
August 29, 2015 14:09
-
-
Save vyder/82986c53021dff06e033 to your computer and use it in GitHub Desktop.
Octopress - :mass_edit rake task
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
| … | |
| 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