Ciao Mark S.
It works! :-)
Some initial comments .
*Tested on ...*
Windows 10 64-bit tablet
Browsers: Vivaldi, Firefox, Edge, Chrome, 2 other Chromium
TEETHING PROBLEMS
-- PowerShell would not run the script till I ran the (session only)
command ...
"Set-ExecutionPolicy -scope CurrentUser -executionPolicy Unrestricted"
I'm not sure that's a healthy way to do it, but it worked :-).
BROWSERS -- SMALL ISSUE
To my surprise not all modern browsers save the version number exactly the
same way. Both "name (2).html" and "name(2).html" occur.
STEMMING
I don't understand how to do it but I think the stemming issue with
possible overwrite could be avoided by using a regular expression rather
than the general wildcard?
This looks like it might work ....
"$stem(\s*\(\d+\))?$"
But I'm unclear how PowerShell invokes the matching it can do (
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_regular_expressions?view=powershell-6
).
INSTANCES?
Just a thought for later. Based on my working practice.
In actual usage I'd be more likely to set "$waitSeconds" to 600 since I
don't write that much.
What I'm interested in knowing is if one could run a second instance of the
script--identical except it just does a restore of wiki and then exits?
An "Instant Restore".
The case use is a common one for me ... I installed a plugin and need to do
a refresh. Rest of the time I rarely need a restore, just saves (downloads).
FURTHER TESTS
--- I will play with running it via a batch file.
--- See how it works with portable addressing (not for download folder, but
for everything else).
Many thanks!
Josiah
On Monday, 20 May 2019 23:41:19 UTC+2, Mark S. wrote:
>
> I'm not a PowerShell aficionado, so even a short script takes some time.
> If you're feeling daring, and have *backups*, you can try.
>
> At the top of the script is a list of your file stem names. They should
> match the capitalization of your real files because sometimes Windows gets
> confused.
>
> The second list is the list of the directories those respective stems go
> in. There should be a one-to-one correlation. Maybe tomorrow I will learn
> how to split out file name/paths so that two lists are not necessary ;-)
>
> There's a variable that sets how many seconds to wait before checking the
> files again. I have it set to 10 seconds.
>
> To launch, open a powershell, go to the downloads directory used by your
> browser, which should also be where you put the script, and type
> ./launch_all_tw.ps1 <enter>
>
> To launch from a regular batch file would take a magic invocation, so
> that's why I'm starting with the powershell.
>
> I had to add a kludge factor of 1 second to get the datestamp to compare
> correctly. Possibly this would mean that if you did two rapid-fire changes
> in a row, the 2nd one might not be picked up. But I don't know. It might be
> fine.
>
> A script for Linux would be similar, but need completely different code.
>
> -- Mark
>
>
>
>
> # File Stem names. Capitalize per actual file name.
> # Stem must be absolutely unique! Otherwise it might detect wrong file.
> $stemlist = @("notes","Todo")
>
> # List of target directories in same order as stem names
> $dirlist = @("D:\data\Wikis\notes","D:\data\TW2014")
>
> # How many seconds to wait before checking again.
> $waitSeconds = 10
>
> #-- SOURCE DIRECTORY -- NOT USED YET ----------
> $downloaddir = "C:\Users\Mark\Downloads"
>
>
> while(1) {
> for($i=0;$i -lt $stemlist.Length; $i++) {
> $stem = $stemlist[$i]
> $stem
> $dir = $dirlist[$i]
> #$dir
> $copyme = ls $stem*.html | sort LastWriteTime | select -last 1
> $copyme = $copyme.FullName
> #$copyme
> $destination = Get-Item "$dir\$stem.html"
> $source = Get-Item "$copyme"
> #echo Source: $source.LastWriteTime
> #echo Destination: $destination.LastWriteTime
> If($source.LastWriteTime -gt $destination.LastWriteTime.addSeconds(1
> ) ) {
> #echo "Source: " $source.LastWriteTime "greater than "
> $destination.LastWriteTime.addSeconds(1)
> Copy-Item $copyme -Destination "$dir\$stem.html"
> echo "Copying $copyme to $dir\$stem.html"
> } Else {
> echo "Will not be copying"
> }
> }
> echo "Going to sleep..."
> start-sleep -seconds $waitSeconds
> }
>
>
>
>
>
>
> On Monday, May 20, 2019 at 6:05:35 AM UTC-7, @TiddlyTweeter wrote:
>>
>> At the moment, on modern browsers, saving TW without any custom saver,
>> means the save ends up in "Downloads".
>>
>> We have no tool to "auto resurrect" and copy back that save for those
>> kinds of saves. Copying back has to be manual and can get complicated in a
>> forest of downloads.
>>
>> The more I think about this the more odd it seems.
>>
>> I mean, with an "AUTO-RESTORE" from saves in Download to a wiki directory
>> ANY browser could be used and with ANY version of TW. We would not be
>> dependent on specific solutions.
>>
>> Any thoughts on how to do this? And its probable value?
>>
>> I know Mark S. has thought about it.
>>
>> Best wishes
>> Josiah
>>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/e4c5e481-a5e2-434d-a41a-c657feb5da31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.