Search within BBEdit docs, possible?

It isn’t possible for DT Pro (3.9 on 13.3.1) to search within imported BBEdit documents, is it?

What kind of BBEdit documents do you mean? BBEdit saves text files which will can be indexed fine by DT.

1 Like

I have regular BBEdit-format text files imported (not indexed) into DT Pro.

The Search Inspector of course finds the files by filename.

But if I search inside one, DT fails to find such a string:

What am I doing wrong, please?

Weird. It’s not immediately obvious what’s happening there. In principle, DEVONthink should have no problem searching inside files created by BBedit, whether those files are imported or indexed.

As mentioned by @ptrs, BBedit is aimed at editing text files, which is the most basic file format. So, to answer your original question, yes it is possible for DEVONthink to search inside files created by BBedit. Once imported in DEVONthink, you can edit them there, or open them in BBedit by (e.g.) right-clicking the item to get the contextual menu and using the Open with item. The edited results should again be searcheable in DEVONthink.

As to what is happening in this particular case, maybe someone else will have some ideas …

1 Like

Thanks, @mhucka!

(So maybe it’s not just me :slight_smile: ?)

When I first started using DT, I asked a few questions here about its handling of BBEdit files. Jim and others kindly explained to me that DT uses macOS’s/the Finder’s launchdb to determine what to do with BBEdit-format files, since - IIR - they need ‘special treatment’ because they’re not native and need to be distinguished from TextEdit/.txt/.rtf etc file.

But, as you rightly say, I can always retrieve, edit and then save etc BBEdit-format files right from within DTP.

I usually get ‘Unknown format’ when I import a BBEdit file into DT. And I’ve assumed that’s because of the above.

Could the fact that I’m not (‘consciously’) associating my BBEdit files with a filetype which DT recognizes be causing this? Because DT does not index their contents?

Grateful for any pointer, please: I rely on BBEdit a lot!

TIA…

Hmm. I can’t speak to the previous discussions, but just to confirm (more to myself than anything) that I’m not crazy or talking out of my ass, I did the following test:

  1. Installed BBedit version 14.6
  2. Started BBedit
  3. Wrote 2 lines of very unique text in the window that it opened
  4. Saved the file as a “file from bbedit.txt”
  5. Switched to DEVONthink pro 3.9
  6. Dragged the file from the Finder into an existing database in DEVONthink
  7. Used ⌘⌥f in DEVONthink to search in the database for a line that I know existed in the file I wrote in BBedit

and DEVONthink found it.

The nice thing about this test is that I only recently got my current Mac, and I did a clean install of everything (not using Migration Assistant [1]), and I did not have BBedit installed before today, so there could not have been any prior file associations or other connections between .txt files and BBedit on this computer [2]. This is about as close to off-the-shelf behavior for this combination as one could hope for.

So, my conclusion from this is that whatever is happening, it is not due to an inherent limitation of DEVONthink with respect to files created by BBedit.

Footnotes
[1] Yes, it was extremely time-consuming and painful to do it this way. I did it because for the previous >10 years, I’ve always migrated Macs when getting new machines, and this time I wanted to avoid the accumulated cruft that comes from doing it that way.

[2] My normal association for .txt files in the Finder is for Emacs, not whatever comes from macOS by default, but that shouldn’t affect this test.

1 Like

Thanks. I believe that may be because of your step #4, @mhucka: you specifically gave your file the extension, ‘.txt’.

May I ask you to see what happens if you repeat steps 2 to 7 with a file (Yes, created and/or edited in BBEdit) that has no extension (or, for that matter, a spurious extension - like ‘.tbt4’ !)?

I deliberately do not add .txt to my BBEdit files - lest they get opened with TextEdit!

And I agree with your conclusion: I don’t think it’s anything odd - or even unexpected - in the way DT is behaving. It’s following the way macOS is supposed to handle (such) files.

Ideally, though, I’d like to be able to search inside my BBEdit files without having to add a .txt extension to them all - for the reason stated above: that they would lose their BareBones-specific identity :slight_smile:

I think this may the issue. I suspect DT may look at the file extension to determine whether it can open/index the file (although if that is the case, it’s not something I’ve realised or thought about before).

Just to be clear, there’s no such thing as a BBEdit file - you’re just saving a text file without the extension.

Could you not just save your files with a .txt extension and right-click one, select ‘Open with’, select BBEdit, then tick ‘always open with’?

Edit: just saw your comment about BBEdit-specific identity. If you tell Finder to always open .txt files with BBEdit, they should get a BBEdit icon.

2 Likes

Very interesting! Yes, the behavior is different: it doesn’t find the text then. Hmm … I don’t have time to investigate this further right now, but that was unexpected (to me).

With respect to this:

Are you aware that you can change this association between .txt files and TextEdit? If you want .txt files to be opened in BBedit by default, you can simply do the following:

  1. Find a .txt file in the Finder
  2. Press ⌘i to open the Info panel
  3. Look for the “Open with:” section of the panel, and change the value in the pull-down
    image
  4. Click the “Change All…” button below the pull-down.

That will make it so that files with a .txt extension are opened using BBedit instead of TextEdit by default.

1 Like

@ptrs, @mhucka - I hear you :slight_smile:

Thanks so much for your investigation and guidance!

My reluctance to do that is based upon the fact that then any (other) TextEdit files, whose default extension is ‘.txt’, would also open in BBEdit, thereby preventing me from using TextEdit’s formatting etc.

IOW it may not be possible to maintain two types of such text file, each with its own extension, and have DT distinguish between them, being able to search the contents of each/both.

Hold on. If you have a true text file, then TextEdit will not show or provide formatting such as bold face or similar – those are features that are not inherently possible in text files, unless you rely on markup of some kind (e.g., Markdown, HTML, LaTeX, whatever) and the program interprets the markup to display the text in a different way. That’s something TextEdit doesn’t do. Once you do something like put a word in bold face, then when you save the file, TextEdit will not it as a text file but rather as (probably) RTF, in order to preserve the formatting.

Is it possible that those files created in TextEdit and given .txt extensions are not really text files, but rather files in (say) RTF format, saved to a file named with a .txt extension? If so, I would recommend not giving them a .txt extension, to avoid the confusion that comes from this situation.

1 Like

Thanks, @mhucka - I guess you’re right. The TextEdit files are Rich Text. Their extension by default is indeed ‘.rtf’. As is the default format for TextEdit. Your reminder appreciated!

So, Yes, in theory I could change the extension for BBEdit files to .txt and achieve two things at once:

  1. distinguish them from all those TextEdit files which really should be and/or are Rich Text
  2. make them (the BBEdit files) searchable from within DT.

Yes?

My concern about #1 is that I have hundreds of (such) text files transferred, handed down, inherited over 40 years (I began using a computer in the early 1980s) which actually aren’t Rich Text and so whose extension is legitimately text. And which I usually open in TextEdit because macOS so associates them.

Me too!

It’s actually possible to determine the type of content in a file regardless of its extension, and it would be possible to search for all files of a certain kind and change their properties (like associations) or rename them. Unfortunately, the only ways that come to mind involve some arcane Unix command pipelines in a terminal, probably coupled with some scripting, and trial and error …

However, I suspect that there exist Mac utilities that would let you do this somehow. Maybe someone else in these forums knows of something applicable.

2 Likes

Well, there’s the file command that does not involve pipes out any such thing.

This is as inaccurate as talking about “BBEdit files”. Both programs are editors and can conceptually work with a lot of file types, eg plain text, TeX, HTML, Markdown, CSS, JavaScript.
All of these are plaintext formats, as is RTF. BBEdit can open RTF files just fine, as can Emacs or VS Code for that matter.
There simply is no such thing as a “TextEdit file” or “BBEdit file”. And associating any meaning with a file extension is nothing more than a convention from old ages and operating systems long gone.
DT considers arbitrary file extensions as text if you tell it so by setting a “hidden preference”. It’s described in the manual yet this heading and has been here regularly.

2 Likes

file reports the type of a file, but I was talking about changing associations between file types and applications, which requires more than just file.

2 Likes

Thanks again, @chrillek, @mhucka!

I shall look into this further.

At heart I need to be able to both open files created in BBEdit and files created by Textedit in the Finder every time with those apps, respectively.

And to be able to search inside files saved with BBEdit (I completely take your point, thank you, @chrillek, about types) in DT.

I wonder whether A Better Finder Attributes could help?

Both Finder and DEVONthink have the “Open with …” feature, so does that not do what you seek? You, not the computer, can pick the app you prefer.

Thanks, @rmschne Yes, I can use the Open with… :slight_smile:

Of course it always works perfectly in DT. (And BTW this is in no way a criticism of DT!)

I’d prefer to have files created in BBEdit open from/in DT without having to do that… I use them a lot. And be able to search in BBEdit files in DT.

But it’s even more important that I (continue to) distinguish between files originally created in BBEdit from those originally created in TextEdit - because I do use the features (e.g. BBEdit’s line number and sorting; TextEdit’s ability to add (RTF) formatting… headings etc) of each app differently (both inside DT and from the Finder).

Well, as posts above, distinguish by using file extensions, and inform the macOS those defaults?

What you might want is that files are opened by default with these apps, ie when you double-click on the file. Perhaps.

As has been pointed out many times: This is in no way related to DT. It’s what you set in Finder as the default app for files with a certain extension. Neither Finder nor any other program cares a bit about the app you used to create those files (The times of the four letter creator code are long gone). Why would it, and how could it? You can create (as said before) text files (including MD, CSS, HTML, JavaScript, whatever) with any editor. And you can open them in any editor. If you want a particular editor open files with a particular extension, tell the Finder, and it’ll make sure that happens. As will DT, because it simply uses macOS’ underlying framework for that.

Again: There is no BBEdit file. And they don’t gain a magical existence by stating the name, either. Use the extension you like to identify them, tell DT to treat that extension as text, and tell the finder to open all files with this extension in BBEdit. That’s all the magic you need (and all the magic you’ll get, too).

2 Likes