Grabbing a bunch of tags

I concur. I think this is a good task for a stamp. That is run once, on all selected notes, when you press the ‘Apply’ button on the Inspector (or click the stamp menu item).

Here’s a solution using grep.

It doesn’t require an external script file with chmod and all that. Just put this code in a stamp, select the notes, and Apply the stamp to them.

$Tags=runCommand("grep -o '#[a-zA-Z0-9_]\+'",$Text).replace('\r',';')

1 Like

Better solution than mine. I’ve deleted my other posts.

Still need to replace the hash, though. See the OP.

Ah, yes. Appending another .replace does the trick.

$Tags=runCommand("grep -o '#[a-zA-Z0-9_]\+'",$Text).replace('\r',';').replace('#','')

2 Likes

This is awesome! There is so much to learn just from this one line of code… Thanks a lot!

This is really cool. Thanks Sumner Gerard. This allows a lot of flexibility to search for anything in the text and act on it (without needing explicit files for each type of search).

1 Like

So now I’m having a separate issue. Not sure if I should post it here or start a new thread, but here it goes:

I’m grabbing a set of people mentioned in the notes and eventually creating links to notes of those people. This chunk of code

$Mentions=runCommand(“grep -o ‘@[a-zA-Z0-9_]+’”,$Text).replace(‘\r’,‘;’).replace(‘@’,‘’);
$MySet=“”;
$Mentions.each(m){
$MyString =$FullName(find($FullName.replace(" “,”").substr(0,m.size).lowercase == m.lowercase));
$MySet=$MySet+$MyString;
};

grabs all the people tagged with a @ and puts them in a set attribute I created called $Mentions. Since the mention may only be a partial name (i.e. pete instead of Peter) I am trying to truncate the search string to match the length of the mention. I also convert both to lowercase so that cases don’t have to match and remove the space between the first and last name so that a search for “peters” will match “Peter Stouffer”.

But this doesn’t work! It returns an empty set.

However if I change the line to

$MyString =$FullName(find($FullName.replace(" “,”").Preformatted textsubstr(0,4).lowercase == m.lowercase));

and search for “pete” it works. It seems that the size function is not working in this case. It also doesn’t work if I assign

$MyNumber = m.size;
$MyString =$FullName(find($FullName.replace(" “,”").substr(0,$MyNumber).lowercase == m.lowercase));

Only a discreet number works in this case. All other attempts to use .size seem to be working properly. Any thoughts?

In the last case $MyNumber fails as you’re using the wrong context (I think), i.e. the $MyNumber for each item being tested and not the item calling the find(). I think for the latter you should use $MyNumber(that). Anyway, just to clarify the process and capturing values like m.size in attributes I tried using collect():

$MySet2="";
$MyString='';
$MySet.each(m){
   $MyString2=m.lowercase;
   $MyNumber=$MyString2.size;
   $MyString =collect(find(($FullName.replace(" ","").substr(0,$MyNumber(that)).lowercase)== $MyString2(that)),$FullName);
   $MySet2=$MySet2+$MyString;
   $Text = $Text + $MyString2 + "\n";
   $Text = $Text + " " + $MyNumber + " || " + $MyString +"\n";
   $MyString2=;
   $MyNumber=;
};

The upshot is the indication is that the section $FullName.replace(" ","").substr(0,$MyNumber(that)).lowercase is not getting evaluated as suggested.

There’s quite a nested level of operation here and I’ve no idea if the operators involved. I’d ask Eastgate - noting that MB is en route home from HT’17 so may not be around for some hours yet.

This looks like a really nice way to speed-scan and tag text. Thank you!

If this feature request been made, I second it.

I have started using @pat’s great Publish from Tinderbox to DEVONthink My only problem with it is that my tagging system gets broken due to Tinderbox not exporting #Tags to Finder tags.
I read and highlight in MarginNote. This app exports quotations with #tags in their text body to rtf files with Finder tags. When those files are grabbed from DEVONthink into Tinderbox the #Tags attribute is automatically filled. I think it would make sense to equally convert #Tags in the opposite direction.

I agree that Applescript or probably xattr can be a solution. I understand it is not discussed in the posts below how to implement it. Has it been implemented by any other user who can advise on how to do it?

Google? I found this: Applescript-xattr - Apple Community

Sure, I did Google before posting my question. But neither the link you have kindly suggested nor Tagging files from the macOS command line - BrettTerpstra.com seem to me straightforward to integrate with Tinderbox’s $Tags. At least not for my level of computing skills.

Besides my own computing shortcomings, I think it is reasonable to expect that Tinderbox adopts a seamless way to handle Finder tags (when exporting, watching folders, etc), as DEVONthink, Marginnote and other good apps used for research do. I for sure would welcome it.

Need to be a bit more precise here. Pat’s method uses a script to directly create a note in DEVONthink, using data in your Tinderbox file, and then update existing notes. There’s nothing going on in Finder with Pat’s Publish from Tinderbox to DEVONthink. So, his script can be modified to create and update tags, because the commands used by his script can write tags to DEVONthink. So, this has nothing to do with any Tinderbox enhancement controlled by Eastgate or Tinderbox “exporting … to Finder” – instead, you’d need to convince Pat to change his script.

I assumed @pat doesn’t want his Tinderbox $Tags in DEVONthink, as I do. This is why I was hoping to modify the script myself. But I can’t. Therefore, I follow your suggestion and hope he can take into consideration to add this feature to the script in the future, as I think it would probably be useful for other users.

Alternatively and although I so far have a minimal grasp of Tinderbox export (just enough to have set up a few simple templates), I do wonder if it would make sense for Tinderbox to add a specific export ^action or ^value to easily transform #Tags into Finder tags?

But for what? The exported data file? The xattr data (resource fork in Mac of old) is stored separately from the actual file itself.

Tinderbox does export $Tags to DEVONThink.

As it happens, I’m currently helping another MarginNote user (privately) with this issue and it’s quite plain the problem here is lack of functionality in MarginNote. As it’s not a cheap app, why not get the MarginNote dev to give you decent import export rather than try an make other apps deal with MarginNote’s lack of functionality?

1 Like

I suppose we are talking about different issues here, because MarginNote exports its tags by default to DEVONthink (File > Export Notebook > DEVONthink). Firstly, as Apple tags of rtf files, and from these into DEVONthink.

As for the exporting of Tinderbox tags into DEVONthink, I better post in the dedicated thread to the script. Thanks for your replies.

I’m not a regular DEVONthink user, so others can check this, but my understanding is copying items to DT does pass Tinderbox $Tags into the DT tags, as of Tinderbox 6.4.0 and DEVONThink v2.8.8.

My earlier point - this seems the only way MarginNote has to export such data which seems pretty inflexible.

In the (private) thread I mentioned I think the MN user is manually putting the ‘#Tags’ into the exported text files and I’m helping him remove these from $Text, clean off the MN clutter (hashes, underscores) and place it in $Tags.

Even in the Pro MN version (needed for most export types) looks pretty limited for export and is tied to a few target apps some of which require a further third party app en route, e.g. you need OmniOutliner to get to DOCX (according to the MN manual). I can’t check further as there’s no user forum. Frankly, I think it would make far more sense to get the MN dev to offer a CSV or Tab-delim output which Tinderbox and other apps can easily handle rather than push Tinderbox for more niche and breakable (each version of both apps has to be tested for unintended breakage) bespoke export/import. My 2¢, anyway.

I understand now, and I agree that removing the clutter of #tags in the exported text files is certainly an improvement: they are added automatically and are redundant. There is something similar to a forum in https://marginnote.uservoice.com/, but it is largely unattended.

FWIW, I use MarginNote quite a bit but only export in .mmap format (mind map). Even there, the exports are crammed full of superfluous and ugly formatting. The other export formats need a lot of work, IMO. Not meant to criticize anyone’s use of MN.

Edit: if @eastgate is looking for more examples of artisanal software, MarginNote definitely fits into that category. It would be nice if there were tighter integration – perhaps a “watched” feature for Tinderbox to watch the notes in a given MarginNote “Notebook”.

1 Like

Good to hear there’s an MN forum as fellow users often know odd tricks that haven’t filtered back to the dev (users being driven by need ).

When/if the side task is complete I’ll post more on the MN->TB tag process. TL;DR the aim is to ensure the tags form the last paragraph of each note’s $Text and if multiple tags that they have a consistent delimiter. I think the last needs doing outside MN (if so that’s an issue its dev might be persuaded to fix). Then an action can grab the last paragraph, remove hashes/underscore, replace the value delimiter characters with a semi-colon and set that as the $Tags value. Job done.

Aside, the subject of MN highlights (in RTF) came up. If you export highlighted text to RTF, it should survive in TB. I don’t have MN but have made highlights in TextEdit and drag dropped an RTF into Tinderbox and the highlight is there. Note, Tinderbox itself can remove highlights but can only create highlights in 3 colours (red,green,yellow) - it’s RTF text controls don’t have TextEdit’s custom color well for highlights.

HTH!

1 Like