Here is a PowerShell Script to be run from Shell and create a WikiFolder form any TiddlyWiki single html file (like mynotes.html). It uses File System Path configuration as explained in https://tiddlywiki.com/#Customising%20Tiddler%20File%20Naming to create nice folder structure.
File name: singlefilewiki_to_wikifolder.ps1
File content:
param (
[string]$ExistingWikiPath = "G:\TW\000. Notes\dailynotes.html"
)
$date = Get-Date -Format "yyyy-MM-dd"
$baseFolderName = "daylinotes-wiki-$date"
$folderName = $baseFolderName
$counter = 1
while (Test-Path -Path $folderName) {
$folderName = "$baseFolderName-$counter"
$counter++
}
New-Item -ItemType Directory -Path $folderName
Set-Location -Path $folderName
tiddlywiki . --init server
New-Item -ItemType Directory -Path "tiddlers"
$fileContent = @'
title: $:/config/FileSystemPaths
[is[system]!has[draft.of]removeprefix[$:/]addprefix[system/]]
[is[draft]search-replace:g:regexp[/|\\],[_]addprefix[drafts/]]
[tag[task]addprefix[mytasks/]]
[!tag[externalnote]addprefix[wiki/]]
'@
Set-Content -Path "tiddlers/file-system-path.tid" -Value $fileContent
tiddlywiki . --load $ExistingWikiPath
tiddlywiki . --listen port=8080
How it works:
- It accepts the single file wiki full name (including path, if file is on other drive/foler)
- it creates a wiki folder like
daylinotes-wiki-$date
, change as you like - if folder existed it adds a number (serial) to the of folder name
- it creates a config tiddler to set the paths for system/draft/wiki tiddlers (change as you like)
- it saves the tiddlers from single file TiddlyWiki into wiki folder
- it then starts the TiddlyWiki at the port=8080 (change as you like)
Remarks
- I used default value for single file TiddlyWiki (
[string]$ExistingWikiPath = "G:\TW\000. Notes\dailynotes.html"
) change as you like. This will used by default - You can call it like
.\yourscript.ps1 -ExistingWikiPath "\path\to\ExistingWiki.html"
Requirements
- Installed Node.js
- Installed TiddlyWiki on Node.js
- Windows 10 or above (if you have other OS, you need to have PowerShell installed)
Acknowledgement