[tw] First pass at a Powershell launch script file for TW files
(too old to reply)
'Mark S.' via TiddlyWiki
2017-07-24 20:30:00 UTC
Raw Message
The default mechanism for saving in both Firefox and Chrome is to write out
files with names like


This doesn't typically put your files where you want them, or with the name
that you want them.

Since TiddlyFox is going away, it occurred to me that one way around this
is to use a script file to pick out the latest tw file and launch it for
you. It turns out that the powershell (tm) code is pretty simple (so far).

To run this, you need Powershell, of course, which I believe comes standard
with Windows these days.

I put a file, launch_tw.ps1 in the same directory as the default downloads:

param([string]$stem="foo", [string]$dir="")
$copyme = ls $stem*.html | sort LastWriteTime | select -last 1
$copyme = $copyme.FullName
Copy-Item $copyme -Destination $dir\$stem.html
Invoke-Item $dir\$stem.html

Then, for each TW file I want to launch I put a batch file (e.g.
"launch_tw_fun.bat") in the same directory:

powershell -executionpolicy bypass -File .\launch_tw.ps1 -stem "tw_fun" -dir

The bt file indicates the stem name of the target file and the directory
where to put the selected file. AFAIK It's necessary to use a bt file to
launch the ps file because there is otherwise too many security
restrictions on ps files. But perhaps power users would have a better way.

You can copy the batch file from explorer and make a shortcut to it on your
desktop for easy access.

Then, to start a session, you double click on the shortcut and the TW file
comes up in your default browser. You save the same way you've always done
using the default mechanism.

Although this was done with powershell, I'm sure the same thing could be
worked out in script files for other platforms.

I haven't tried or worked out yet what happens if you have file and
directory names with spaces. One thing at a time.

This version doesn't delete anything, so it's up to the user to
occasionally clean up their download directory.

Stem names need to be unique. If you have tw_fun.pdf and tw_fun.html there
is a possibility that your browser will launch a PDF file (if the PDF
happens to be newer).

If you try this, remember it's all experimental. Be sure to make backups!

You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/0e7eba7f-e974-4e5f-bed0-e7abf45d7689%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.