Support for files without extensions

my primary notes collection goes back over 25 years (19,000+ files) - the number of files that have file extensions at all is in the double digits… those that do tend to be .save and .save.1 editor artifacts…

while I could automate the renaming of all of the files (not really, that’s not very safe either), it seems like it would be a great option (even if it’s a configurable option) to be able to not exclude those files from the vault views.

a simple “treat everything as plain text or markdown” option for otherwise unknown files, with a basic “this file might be binary” check, would go a long way for users like myself.

5 Likes

mod note: this post originally referred to both .txt and no-extension files, but there’s a .txt discussion already, so I modified this one to separate the two requests.

1 Like

Hi All

I have only just started with Obsidian and find it my goto after only about a month. Excellent tool.

I am a software developer so I needed something to collect various snippets, I will now use this for the project design and eventually documentation, including links to sources etc. all my todo lists, daily notes, meetings, project tasks, etc. all in the one place.

So to my test setup.

Setup

These are my plugins, which work great together

  1. Daily Notes
  2. Templater
  3. Templates
  4. Page Preview
  5. Editor Syntax Highlight
  6. txt as md

I have a Scripts Folder within the vault, this works for me to test, but will become a project folder in the future.

  • \Obsidian\
    • Scripts\ “or Projects”
      • bas
      • js
      • txt
      • noExtension
      • etc.

Assuming txt as md is installed, go to your [.obsidian\plugins\txt-as-md-obsidian] obsidian folder and edit the file [main.js]

Once finished it should look like this

var TxtAsMdPlugin = /** @class */ (function (_super) {
    __extends(TxtAsMdPlugin, _super);
    function TxtAsMdPlugin() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TxtAsMdPlugin.prototype.onload = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                _super.prototype.onload.call(this);
                // register the view and extensions
                this.registerExtensions(["txt"], "markdown");  
				this.registerExtensions(["bas"], "markdown");  <--- ADD
				this.registerExtensions(["js"], "markdown");   <--- ADD
				this.registerExtensions([""], "markdown");     <--- ADD
                return [2 /*return*/];
            });
        });
    };
    return TxtAsMdPlugin;
}(obsidian.Plugin));

Of course don’t add the “<— ADD”

Once you have added your extensions save the file and reopen your Obsidian vault, Obsidian can now read and edit the files that you have added above.

As an example the raw text file “StrHash64.bas” looks like this

Public Function StrHash64(text As String) As String
    Dim i&, h1&, h2&, c&
    h1 = &H65D5BAAA
    h2 = &H2454A5ED

    For i = 1 To Len(text)
        c = AscW(Mid$(text, i, 1))
        h1 = ((h1 + c) Mod 69208103) * 31&
        h2 = ((h2 + c) Mod 65009701) * 33&
    Next

    StrHash64 = Right("00000000" & Hex(h1), 8) & Right("00000000" & Hex(h2), 8)
End Function

It shows in obsidian as, maybe not pretty but its workable

You can edit this file just as if it were a markdown.

I use templater to then add a header such as

This of course is not a bas file anymore, but it dos’nt take much to convert it back, and usually I just copy it out of obsidian in any case.

There are still some things I want to add, for example some JS to create a markdown file and then import the file into it. That would eliminate some manual intervention that was required above.

Hope this helps someone

cheers

tom

like this → this.registerExtensions([“py”,“txt”,“js”], “markdown”);
:sunglasses: