Skip to content

Instantly share code, notes, and snippets.

@jameshibbard
Created May 5, 2015 19:07
Show Gist options
  • Save jameshibbard/e1c08c8a58b471b602d6 to your computer and use it in GitHub Desktop.
Save jameshibbard/e1c08c8a58b471b602d6 to your computer and use it in GitHub Desktop.
Archive Trello cards from a specified list, which are older than a specified date
# Archive Trello Cards Programatically
#
# Get TRELLO_DEVELOPER_PUBLIC_KEY from:
# https://trello.com/1/appKey/generate
#
# Get TRELLO_MEMBER_TOKEN from:
# https://trello.com/1/authorize?key=TRELLO_DEVELOPER_PUBLIC_KEY&name=Arch&expiration=never&response_type=token&scope=read,write
# substituting TRELLO_DEVELOPER_PUBLIC_KEY for your actual key
#
# Get BOARD_ID (alphanumeric string, found in the board's URL):
# https://trello.com/b/BOARD_ID/BOARD_NAME
#
require 'trello'
TRELLO_DEVELOPER_PUBLIC_KEY=""
TRELLO_MEMBER_TOKEN=""
BOARD_ID = ""
LIST_NAME = "Published"
YEAR = 2015
Trello.configure do |trello|
trello.developer_public_key = TRELLO_DEVELOPER_PUBLIC_KEY
trello.member_token = TRELLO_MEMBER_TOKEN
end
board = Trello::Board.find(BOARD_ID)
cards = board.lists.select{ |l| l.name == LIST_NAME }.first.cards
old_cards = cards.select{ |c| c.due.year == YEAR }
old_cards.each do |c|
puts "Closing #{c.due.strftime("%Y-%m-%d")}: #{c.name}"
#c.close!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment