How do I get the 'created' or 'modified' fields to populate on import?

83 views
Skip to first unread message

Joshua Baller

unread,
Jul 20, 2020, 12:39:00 PM7/20/20
to TiddlyWiki
I have a wiki (5.1.22) that is partly updated through importing large sets (1000s) of tiddlers from a few JSON files on an approx. weekly basis (knowledge base, the information is being maintained and updated on a different system). I would like to know the last edit/update dates for a particular tiddler was imported in this way, however when imported the 'created' and 'modified' fields are left blank.

My preference would be to simply have the field populated on import as this seemed like the expected behavior. Is there a setting I'm missing to get this to occur? Otherwise is there are way to target only the recently imported tiddlers to have their 'created' dates populated?


Eric Shulman

unread,
Jul 20, 2020, 1:07:18 PM7/20/20
to TiddlyWiki
On Monday, July 20, 2020 at 9:39:00 AM UTC-7, Joshua Baller wrote:
I have a wiki (5.1.22) that is partly updated through importing large sets (1000s) of tiddlers from a few JSON files on an approx. weekly basis (knowledge base, the information is being maintained and updated on a different system). I would like to know the last edit/update dates for a particular tiddler was imported in this way, however when imported the 'created' and 'modified' fields are left blank.

My preference would be to simply have the field populated on import as this seemed like the expected behavior. Is there a setting I'm missing to get this to occur? Otherwise is there are way to target only the recently imported tiddlers to have their 'created' dates populated?

While it might seem to you to be the expected behavior, importing tiddlers will NEVER add or alter any fields in the incoming tiddlers.  This is by design, since there may be unwanted side-effects of changing the tiddler definitions, even if it is just to add a "created" or "modified" date.

However, you *can* perform a "fixup" process after importing, by using the following button:
<$button> set missing created/modified fields
<$list filter="[all[tiddlers]!is[system]!has[created]]">
   <$action-setfield created=<
<now "YYYY0MM0DD0hh0mm0ss0XXX">> modified=<<now "YYYY0MM0DD0hh0mm0ss0XXX">> />
</$list>
</$button>

This button does a $list to find all tiddlers that do not have a "created" field
(excluding system tiddlers... those starting with "$:/").  For each tiddler it finds,
it sets the "created" AND "modified" fields of that tiddler to the current datetime,
using the standard 17-digit TWCore date format for those fields.

enjoy,
-e


Joshua Baller

unread,
Jul 20, 2020, 1:47:06 PM7/20/20
to TiddlyWiki
 While it might seem to you to be the expected behavior, importing tiddlers will NEVER add or alter any fields in the incoming tiddlers.  This is by design, since there may be unwanted side-effects of changing the tiddler definitions, even if it is just to add a "created" or "modified" date.

Yeah, perhaps 'expected' behavior was the wrong choice of words.

Thanks for the snippet, that seems like a good fallback solution.

One other thought I had was to parse the $:/Import tiddler for a more targeted list of tiddlers to modify, but I can't think of a straight forward way of doing that.

Saq Imtiaz

unread,
Jul 20, 2020, 2:05:05 PM7/20/20
to TiddlyWiki
@Joshua

One other thought I had was to parse the $:/Import tiddler for a more targeted list of tiddlers to modify, but I can't think of a straight forward way of doing that.

[[$:/Import]links[]]


Saq Imtiaz

unread,
Jul 20, 2020, 2:05:55 PM7/20/20
to TiddlyWiki
Potentially this thread might be of interest as well:

Joshua Baller

unread,
Jul 20, 2020, 2:28:23 PM7/20/20
to TiddlyWiki
Beautiful, thank you. I was unfamiliar with the 'links' keyword.

TW Tones

unread,
Jul 20, 2020, 5:49:29 PM7/20/20
to TiddlyWiki
Josua,

Remember that tiddlers you may import, or other files may bring created or modified dates with them. These dates can be meaningful so I recommend against changing them. I am building additional import tools but they are not ready yet, however post import you get a list of imported tiddlers you can extract using the list[] operator, a button that set a new import-date field to now or the import tiddlers created date, using $timestamp=no would record the import date without changing the import tiddlers created and modified dates. Giving what you want but retaining fundamental information that may prove useful in the future.

Don't compromise your future!

Regards
Tony

Eric Shulman

unread,
Jul 20, 2020, 6:19:47 PM7/20/20
to TiddlyWiki
Combining my "fixup" button solution with Saq's idea about getting the links directly from the $:/Import tiddler, gives the following:

<$button> set missing created/modified fields
<$list filter="[[$:/Import]links[]!has[created]]">
   <$action-setfield created=<
<now "YYYY0MM0DD0hh0mm0ss0XXX">> modified=<<now "YYYY0MM0DD0hh0mm0ss0XXX">> />
</$list>
</$button>

-e


Mat

unread,
Jul 20, 2020, 7:49:42 PM7/20/20
to TiddlyWiki
Also this might be of interest:


<:-)

TW Tones

unread,
Jul 20, 2020, 8:14:36 PM7/20/20
to TiddlyWiki
I have a solution that I will publish if there is a demand.
  • A view template that appears on the $:/Import tiddler when it has the field status = complete
    • The ability to save (rename as this tiddler has the created/modified date of the import) this to a date/time titled tiddler as an "import record" with a system-object field set to import-record.
  • A view template for tiddlers with the system-object field set to import-record.
    • Uses a list[] filter to extract the list of titles
    • Amongst other tools button(s) to set the import or created dates with or without $timestamp=yes on the imported tiddlers.
    • If you choose to update modified or created, it would enter the recent list
      • I would prefer a separate tab to list tiddler by imported date and not loose the created/modified info if available.
This is part of a larger import tools project I am working on. 
  • My only issue now is how to import with a prefix if desired to import without overwriting existing tiddlers. 
  • This needs intervention in the import to tiddler process before status = complete.

Regards
Tony


Regards
Tony
Reply all
Reply to author
Forward
0 new messages