Feature-request: action on import?

Is there a trick to trigger an action directly after a file-import with the browse widget?
For example, if I import a media file, can I directly write the title of the newly created tiddler to a tiddler that shows this file in a special template?
Or Tag the newly created tiddler in a special way?

P.S.:Since I saw in the answers that there is no direct way I renamed the thread "feature request"

Currently, there’s no automatic post-import processing. However, it is possible to manually invoke some custom wikitext scripting after files have been imported:

Put the following in a tiddler (e.g., “AfterImportActions”)

<!-- GET A LIST OF IMPORTED TIDDLERS BY PARSING THE "AFTER IMPORT" CONTENTS OF $:/Import -->
<$set name=tids filter="[[$:/Import]get[text]splitregexp[\n]removeprefix[#]enlist-input[]]">
<!-- SHOW A BUTTON TO TRIGGER CUSTOM ACTIONS ON ALL IMPORTED TIDDLERS -->
<$button> do After Import actions
<!-- FOR EACH IMPORTED TIDDLER -->
<$list filter="[enlist<tids>]" variable="tid">
   <!-- CUSTOM ACTION EXAMPLE: "If tiddler type is an image, add image tag"
   <$list filter="[<tid>is[image]]">
      <$action-listops $tiddler=<<tid>> $field="tags" $subfilter="image"/>
   </$list>
   <!-- END OF CUSTOM ACTIONS -->
</$list>
</$button>

enjoy,
-e

1 Like

[[$:/Import]links[]] works quite well to extract the titles of imported tiddler after an import. You can add a custom view template to the $:/Import tiddler that displays the button after the import.

3 Likes

Thank you Eric, I also thought on ways to do this with a second click. Or with a third click and a scroll if you count the necessary action with the importpanel.
I will ask whether this is worth a feature-request to add a “silentimport” and an “actions” attribute to the browse widget…

Good points, @saqimtiaz. Here’s an update to my previous wikitext script…

Just tag it with $:/tags/ViewTemplate, and the button will appear at the bottom of the $:/Import tiddler after the import is complete:

<%if [<currentTiddler>match[$:/Import]status[complete]] %>
<$button> After Import Actions
   <$list filter="[[$:/Import]links[]is[image]]">
      <$action-listops $field="tags" $subfilter="image"/>
   </$list>
</$button>

-e

2 Likes

If you have the Tiddler Commander! It shows a button after import on $:/Import and you can use the Swiss knife then :wink: