Thursday, November 15, 2018

Linking Textfiles with Backlinks

Here is a very simple AhK script that opens up or creates text files from their names in a file. It also inserts a back link to the file from which it is created.

^+o:: ;link text files in D:\Texts

SetWorkingDir, D:\Texts

WinGetTitle, Title, A
StringReplace, Title, Title, - Notepad, , All

clpboard =
Send, ^c
thefilename := clipboard

IfExist, %thefilename%
run %thefilename%
IfNotExist, %thefilename%
FileAppend, %thefilename%, %thefilename%
run %thefilename%
sleep, 500
Send {End}`r`n%Title%{Up}

Just select the entire file name, like "start.txt" or "start.rtf", and press ^+o.

You can, of course change the hotkey as well as the directory. It should also work with other file types, as long as they are registered in Windows. The script is not a wiki, of course, but its linking behavior comes close. If you use a rtf files, you have other markup as well. In fact, it is a very rudimentary wysiwyg wiki.

Postscript, Friday, November 16, 2018 at 20:29: I tried a slightly changed version of the script (different hotkey, different directory, changed StringReplace in line 4) with Jarte. It worked, but not reliably, that is, not always. Every once in a while it would not launch the file selected (even though it had done so before) In one sense that does not bother me, as I am more interested in connecting text files. What bothers me is that I cannot explain why Jarte and rtf files don't always work.

1 comment:

Engvarta said...

I went through certain articles on your blog and found it genuinely matching my interest. The way you impart your valuable insights keeping the article relevant and short is praiseworthy. One can speak and practice English in an effective way, just by downloading English Learning App on your own smartphone, which you can use whenever and wherever you want to practice your communication skills with experts.
Practice English app | English Speaking App