Directory listing plugin

In the recent Newsletter, I was exited to see an entry for a directory listing plugin (GitHub - trumad/tiddlywiki-directory-listing: Scans a linux directory, subdirectories & files, and creates a tiddlywiki. Each folder & file becomes a hyperlinked tiddler. Makes it easy to browse and search a file system, and share the listings with others.) as I’d been wondering whether this was possible… but I note it appears to be restricted to Linux… is this possible for Windows?

Many thanks!

1 Like

I would think that you could run this on Windows as well as long as you have Python installed. Have you tried that?

It would also be more accurate to describe this as a script that creates a JSON file with the contents of a directory that can be imported into TW, rather than a TW plugin.

2 Likes

Another approach is to generate a list of folders into a text file then import that as a tiddler. Once in your wiki you can build a tool to generate folder tiddlers all with wiki text and widgets.

If you are interested I can share more details.

1 Like

No I’ve not looked into that… I used to have Python installed but I seem to have deleted it. I have to admit I didn’t realise that was required, although I wondered by there was a .py file listed in the repository.

Okay, fair cop… I was just going by how this was listed in the Newsletter and guess I should have looked more closely before I posted :grinning:

Many thanks for your advice.

I have considered this sort of approach… but, of course, I was hoping for something a little more seamless and less error prone. In fact I was hoping that it wouldn’t be too hard to create something akin to File Explorer (on Windows) or any similar file listing gizmo but with the added advantage of adding text/links/whatever to provide background to the contents of the folder.

I fear my skills are not up to it but I’d be interested in hearing your further thoughts.

Many thanks for your input.

The main problem is, that the browser vendors don’t let us directly read directory content or file content without explicit user interaction. For security reasons, there has to be at least … the browser file open dialogue. We cannot avoid that.

Even with browser AddOns the possibilities are limited.

So if there is an external mechanism that can run independently from the user, that builds a tiddlers.JSON file it will be much easier on the TW side of things :wink:

1 Like

Note that if you use a WebDAV server to serve the single file wikis, you have more options in terms of interacting with the file system. See:

3 Likes

On Windows, you can capture similar information without Python like:

forfiles /s /m *.epub /c "cmd /c echo relpath@file,@fdate,@fsize" > myfiles.csv

But you’ll then have to clean up the file with a text editor. Or, you can write a routine in TW that can extract the data, change \ to /, and create tiddlers that can then be viewed as a structure using the tree macro. You can then use the official comments plugin to annotate the various file tiddlers.

In theory you could also use the official Excel importer to bring in the CSV, but you would have to clean the text, import it to excel, and then export it to xlsx, then import into TW … so the roll-your-own approach is probably easier long-term.

1 Like

I did have a very short look about possibilities with PowerShell on Windows. … There are pretty powerful commands. … But to create something usable it would probably need 4h, since I don’t know PS all too well.

eg:

  • Get-ChildItem -Directory -Recurse … Which returns a recursive list of directories starting from the current directory.
  • Get-ChildItem -Recurse … will return files and directories. … There only needs to be some filtering since it also shows “.git” … “hidden” files which we probably don’t want on Win.
1 Like

Many thanks for all the contributions and apologies for my lack of comment - eight hours in the undergraduate teaching laboratory means I’m a bit frazzled. I will investigate the suggestions when some sort of capability returns.

To capture all folders and subfulders in windows to a file for use in tiddlywiki use the following at the command prompt

dir /s/b /ad > output.txt
output.txt

The second line will open the result in Notepad or the text editor. I like Notepad++

Be aware that modern windows installed have thousands of folders especially under systems folders, these are best avoided perhaps sticking to everything under the documents folder.

Often the path above the documents folder is quite long to start with so it may be wise to remove the prefix. eg: C:/Users\*user*\*onedrive*\Documents and add the prefix back if needed. I did this in Notepad++

Once you copy/import this content into a tiddler, you can set the tiddler to type text/plain. Then access each row using splitregexp[\n].

<$list filter="[[data]get[text]splitregexp[\n]]" variable=new-title>

</$list>
  • You may want to count the number of rows first {{{ [[data]get[text]splitregexp[\n]count[]] }}}
  • With large numbers making the following take place batches and re-startable would be good.

So lets create a tiddler for each folder, my choice of fields is thinking ahead to later.

  • It can take a long time so be patient. In fact it is taking so long I will return later;
  • Note you can leave it as \ and provide the separator on he tree macro
1 Like