Last active
August 29, 2015 13:57
-
-
Save craigeley/9494663 to your computer and use it in GitHub Desktop.
This script finds TaskPaper items in a specific folder completed with this format: "@done(yyyy-mm-dd HH:MM)", moves and converts them into Sifttter format, and then deletes them.
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'time' | |
files = Dir["/Users/USERNAME/Dropbox/Listacular/*.taskpaper"] | |
projects = [] | |
found_completed = false | |
files.each do |file| | |
if File.exists?(file.strip) | |
f = File.open(file.strip, encoding: 'UTF-8') | |
project = File.basename(file).gsub(/.taskpaper/, ' ').strip | |
lines = f.read | |
f.close | |
item = '' | |
content = '' | |
date = '' | |
time = '' | |
lines.each_line do |line| | |
if line =~ /&/ | |
line.gsub!(/&/, 'and') | |
end | |
if line =~ /@done/ | |
item = line.gsub(/@done\(.*\)/,'').gsub(/@due\(.*\)/,'').gsub(/-./, '').strip | |
/@done\((?<t>.*)\)/ =~ line | |
day = Time.parse(t) | |
date = day.strftime('%B %d, %Y') | |
time = day.strftime("%I:%M%p") | |
open('/Users/USERNAME/Dropbox/IFTTT/' + "#{project}" + '.taskpaper', 'a') { |f| | |
f.puts "- #{date} at #{time} - #{item} @done" + "\n"} | |
found_completed = true | |
end | |
if line !~ /@done/ | |
content += line.gsub(/\s*@/, ' @') | |
end | |
end | |
if found_completed | |
open('/Users/USERNAME/Dropbox/Listacular/' + "#{project}" + '.taskpaper', 'w+') { |f2| | |
f2.puts "#{content}"} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment