I have found the overall perfect solution, going around issues with code page - the APPROACH-M, where M means mashup
Apparently it is possible to invoke Command Line codes within PowerShell. And so when being in PowerShell window with a simple code like this
Invoke-Expression "tree K:\YouTube /f" | Out-File "S:\Data\YouTube List.txt"
I create in the Data folder that TXT holding a nice visual tree displaying all of the files from that YouTube folder and its subfolders. And the filenames are not truncated in any way plus they display all of the diacritic signs correctly
So problem is solved? Not untirely
Unfortunately there is the issue of running PS1 scripts themselves from files. If I am not mistaken, as a supposed security measure the mouse double left click / the Open entry from shell menu by default opens PS1 file in Notepad. And so in order to really run them the Run with PowerShell entry from the shell menu must be chosen [instead of Open]. That can be of course changed by navigating in the Registry to
Computer\HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command
and changing the Value data there from
"C:\Windows\System32\notepad.exe" "%1"
to
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "%1"
[or alternatively making this permanent association by using the Open with option available at the shell menu]
But of course it could not be possibly that simply. Because after changing in the operating system the meaning of Open for PowerShell, that PowerShell now stops creating the TXT file at all, informing that
C:\Program : The term `C:\Program` is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
A line:1 char:1
+C:\Program Files Expanded/YouTube List.ps1
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound" (C:Porogram:String) [], CommandNotFoundException
+ FullyQualifiedErrorId :</b> **`CommandNotFoundException`
[That C:\Program Files Expanded\YouTube List.ps1 is where the file with the script is residing]
So right now for me it is either [by default] impossible to run PS1 scripts in a convenient way i.e. in form of files from their shortcuts [because double clicking LNK file will open Notepad thus merely show an evoked script]; or [after de-associating PS1 files with Notepad] it is impossible to run PS1 scripts in form of files at all [because PowerShell tries to read the path to them as some kind of a command]
So there are probably three workarounds to this:
WORKAROUND-1] Do not tamper with how PS1 files are being run [i.e. leave the default behavior] but create a BAT file that will run that particular PS1 file
In theory in CMD this should work
powershell.exe -command "Invoke-Expression "tree K:\YouTube /f" | Out-File "S:\Data\YouTube List.txt""
While when such BAT is executed it flashes the error message
Invoke-Expression : A positional parameter cannot be found that accepts argument 'K:\YouTube'.
At line:1 char:1
+ Invoke-Expression tree K:\YouTube /f | Out-File S:\Data\YouTube List. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
+ CategoryInfo : InvalidArgument: (:) [Invoke-Expression], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeExpressionCommand
And when the same code is executed directly form the prompt line of the CMD window, a pop up windows appears saying
This app can't run on your PC
after closing which it is followed by message
Access is denied.
written in the CMD window
WORKAROUND-2] After de-associating PowerShell with Notepad, fix it somehow to read the path as path
It is mind staggering why and how changing
Computer\HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command
makes the software itself read paths within scripts as commands
WORKAROUND-3] Use some third party software that will turn PS1 file into EXE
I am afraid that similar problems will arise, with paths being read as commands. Or there ill be some others issues
As for the time parameter issue
I tried changing the datetime / yyyy-MM-dd hh_MM_ss to date / yyyy-MM-dd and time / hh_MM_ss while also tampering with the other portion of the code, but I gave it up this, as I am not a programmer. I can operate with just one TXT being created and then overwritten over and over again [as I make multiple copies of that file with other means]