13 4
Sign in to rate

Reset Creation Times

0.01MB. Updated 2013-03-20. Only supports Anki 2.0.x.

Description

Current Version: 2013/03/19 Description This addon will reset the creation date of cards you select in the Anki browser. Cards are processed in the order which they are sorted by the browser, incrementing the new date in that order. Normally you shouldn't change the order of cards (Damien discourages it whenever the topic arises.). However, some users find it beneficial. For example, - Anki adds cards to daily reviews in the order they were added to the deck. - Exported notes to a spreadsheet will also be in that order. - Anki's browser can sort by creation date. You may have added cards over a period of time which has resulted in an order that isn't optimal for you or a new audience. Usage Select a block of cards in Anki's browser, go to Edit->Reset Creation Times, and provide a date when prompted. A common way to reorder a large number of cards: 1. Add a field to your Anki deck. 2. Export the deck to a spreadsheet. 3. Order the spreadsheet rows as you wish. 4. Add an increment to the a column of the spreadsheet (easily done with a spreadsheet formula). 5. Use Anki's import *update* feature to update the new field of your Anki deck with the sequence number column of the spreadsheet. 6. In Anki's browser, sort the deck on this new (temporary) field, select a block of cards, and run this addon. 7. After the deck is ordered as you wish (by created date), delete the field from step #1. The time used is a YYYY/MM/DD date you enter into a prompt. A randomized HH:MM:SS is added to reduce conflicts if you execute this addon multiple times using the same date. (In the future this addon may allow you to specify a time of day.). This addon's changes can be reversed if you use the browser's "Edit->Undo..." feature in a timely manner. Caveats 1. This operation will force a full sync (upload). This is because Anki 2 stores the creation date in the database's key column. Changing the value is as significant as changing the structure of the deck. 2. Anki's browser displays *cards*, but the "created" date comes from the note. This addon affects the *notes* of the cards you select in the browser. Therefore, if a note has two cards, and you select only one, the note's creation date will be changed and reflected in *two cards*. Even though you selected one card it will appear that a card you didn't select was changed. 3. Because the time of day is randomized, it's remotely possible the timestamp may cross into the next day. This is extremely remote because the timestamp is incremented in 20 thousandths of a second. (The random time would have to be very close to midnight for this to happen.). Because of this, it may be desirable to improve this addon to allow for user-specified time of day. In the meantime, you can edit the script to specify your own time. Questions, support Please post questions and problems here: http://groups.google.com/group/anki-addons/browse_thread/thread/0458ba3c002b7de5?hl=en#

Download

As add-ons are programs downloaded from the internet, they are potentially malicious. You should only download add-ons you trust.

This add-on previously supported Anki 2.0. You can download the last version supporting 2.0 here. As Anki 2.0 has been discontinued, no support is available for this version.

All Anki 2.1.x Add-Ons

Reviews

on 1521417600
Throws an error message.
on 1510617600
1) The card info still shows the original date added.

2) To make things easier with the code glitches, just replace the full code with the one below in the .py file (simply copy & paste):

# -*- coding: utf-8 -*-
# Copyright: Matthew Duggan, mostly copied from bulk reading generator plugin
# by Damien Elmes.
#
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
#
# Reset creation times of a block of cards.
#
# For information about how to use, how to report a problem, see this addon's
# download page: https://ankiweb.net/shared/info/1348853407
#
# History:
# 2010/12/17 - New.
# In Anki 1, creation time was at the card level, and kept in its own column.
# 2013/03/19 - Updated for Anki 2.0.8 (by someguy)
# In Anki 2, creation time is at the "note" level, inhereted by all the cards
# created from a note, regardless of when those cards were created. Also,
# creation time is no longer in its own column. It is the note's "id".
# Changing the creation time is a bit trickier now because we have to execute
# SQL to change the note table in a way Anki didn't intend. And, because
# cards are foreign-keyed to the note's ID, we have to execute SQL to change
# the card table too.

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from anki.hooks import addHook
from anki.cards import Card
from aqt import mw
from aqt.utils import getText, showWarning, tooltip
import time
import random

# debug
#from aqt.utils import showInfo

# Bulk updates
##########################################################################

def resetCreationTimes(note_ids, desttime):

mw.progress.start(label="Reset Creation Times: updating...", max=len(note_ids))
mw.checkpoint("Reset Creation Times")

# debug
# showInfo(("Called reset with %s notes") % len(note_ids))

for note_cnt, note_id in enumerate(note_ids):

# debug
# showInfo(("Loop: Processing note id %s") % note_id)

mw.progress.update(label=("Resetting Creation Times: updating note %s") % note_id,
value=note_cnt)

# Ensure timestamp doesn't already exist. (Copied from anki/utils.py
# timestampID function).
while mw.col.db.scalar("select id from notes where id = ?", desttime):
desttime += 1

# Update the note row
mw.col.db.execute(
"""update notes
set id=?
where id = ?""",
desttime, note_id)

# Update the cards row(s)
mw.col.db.execute(
"""update cards
set nid=?
where nid = ?""",
desttime, note_id)

desttime += 10

mw.progress.finish()

return

# The browser displays cards. But, the creation date is on the note, and the
# note can have multiple cards associated to it. This creates a challenge to
# access the notes in the order of the displayed cards. To keep the processing
# simple, this addon preprocesses the cards, gathering the unique note IDs,
# and ensuring there are no surprises (such as the same note referenced by
# cards in different sort locations in the browser).
def identifyNotes(card_ids):

mw.progress.start(label="Reset Creation Times: collecting notes...", max=len(card_ids))
last_nid = ""
nids_ordered = []
nids_lookup = {}

# debug
# showInfo(("Called identifyNotes with %s cards") % len(card_ids))

# Loop through the selected cards, detecting unique notes and saving the
# note IDs for driving the DB update.
for card_cnt, card_id in enumerate(card_ids):

# debug
# showInfo(("Loop: Processing card id %s") % card_id)

mw.progress.update(label=("Reset Creation Times: collecting note for card %s") % card_id,
value=card_cnt)
on 1482883200
About the modSchema() error

I had the same error, indicating it needs 2 arguments.
In the python code, however, it takes none.
For the workaround you need to comment the problematic line by adding '#' in front of it.(Tools -> Add-ons -> Edit(?))
And by reading the comments above it, you can guess that this function is used for invalidating DB which makes you upload the whole into the web.
So you need to check library manually then sync the whole DB to the web.

I had been almost an inch of messing with DB directly, had opened it with a sqlite editor and looked into the structures and keys, until I found this add-on.
Thank you.

P.S. I found that there is already a solution after wrote this.
People, look at the review on 2015-05-09 or go here directly.

https://anki.tenderapp.com/discussions/add-ons/4033-reset-creation-time-add-on-alternatives-it-doesnt-work-anymore
on 1476835200
Error message - does not work

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
File "/Users/dgerred/Documents/Anki/addons/Reset_Creation_Times.py", line 148, in <lambda>
browser.connect(a, SIGNAL("triggered()"), lambda e=browser: onResetTimes(e))
File "/Users/dgerred/Documents/Anki/addons/Reset_Creation_Times.py", line 201, in onResetTimes
mw.col.modSchema()
TypeError: modSchema() takes exactly 2 arguments (1 given)
on 1460332800
Works like a charm!

I've updated the add-on code as per instructions in the link posted on 2015-05-09 and it works as expected. Thanks!
on 1446163200
Works Halfway

If you press the card info, it still shows the original date added.
Everything else works fine
on 1432944000
Sometimes doesn't work

On one of my computer it crashed
The solution recommended by another reviewer works but you need to make the correction on line 201 rather than line 102
on 1431734400
Excellent for cards that need an ordering

Anki is designed for memorising non-sequential information like vocabulary, but I've grown so fond of this program that I've started taking it beyond its intended use. Some of the stuff I need to learn comes in a strict order, such as the slides of a particular lecture, and I just use the "preview" function of the desktop application for reviewing it in its logical order. Trouble is, you can't insert new notes between older ones, unless you create a new field to sort the notes. This addon offers a simple solution by allowing you to manipulate the creation date, thus putting the notes in the desired order without an additional field. Good job!
(And yes, you have to follow the instructions below to make it work, but that's just an extra five seconds)
on 1429056000
Does not work

on 1384041600
A very helpful tool.

I just re-ordered a deck of about 3000 notes. Very helpful. All went smooth.