About using the comment/descript.ion function from external script

English support forum

Moderators: white, Hacker, petermad, Stefan2

Stiltzkin
Member
Member
Posts: 182
Joined: 2004-09-10, 17:15 UTC

About using the comment/descript.ion function from external script

Post by *Stiltzkin »

is there any way of using the totalcmd comment function from an outside script (without any gui or further confirmation)?
or is there any fast way of settings descript.ion comments (which handles all the linebreaks, existing comments and all that stuff)?
Last edited by Stiltzkin on 2021-05-22, 17:52 UTC, edited 1 time in total.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Abou using the comment/descript.ion function from external script

Post by *Horst.Epp »

There is no problem to write anything into descript.ion
as long as your script follows the rules.
Of course its not a good idea to do that while Tc is updating the contents
because of file operations.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
Stiltzkin
Member
Member
Posts: 182
Joined: 2004-09-10, 17:15 UTC

Re: Abou using the comment/descript.ion function from external script

Post by *Stiltzkin »

jeah, i have scripts that work "good enough", but i usuallycall them from inside totalcmd anways.
so i was wondering if i couldn't just use an existing function instead of implementing my own buggy one in every language i happen to be using.
calling a powershell/batch script from a totalcmd button which then calls a java app which modifies a descript.ion file is kinda silly when totalcmd has that functionality already inside.
NotNull
Senior Member
Senior Member
Posts: 266
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: Abou using the comment/descript.ion function from external script

Post by *NotNull »

Another workaround suggestion:

The descript.ion format was introduced by 4DOS, a command prompt alternative. It's successor - TCMD - has a free version, TCC/LE.

With that, you can:

Code: Select all

tcc.exe /c describe "c:\path to\filename.txt" /D"some description"
Stiltzkin
Member
Member
Posts: 182
Joined: 2004-09-10, 17:15 UTC

Re: Abou using the comment/descript.ion function from external script

Post by *Stiltzkin »

jeah, that's something i was looking for. shame it's not just a standalone *.exe.
and i think it doesn't have the same extended functionality as totalcmds comment feature has now (comment length, line breaks,[char]0x04 [char]0xC2)?

would be great if you could use those parameters for the totalcmd.exe.
User avatar
tuska
Power Member
Power Member
Posts: 3742
Joined: 2007-05-21, 12:17 UTC

Re: Abou using the comment/descript.ion function from external script

Post by *tuska »

Stiltzkin wrote: 2021-05-20, 11:59 UTC ... or is there any fast way of settings descript.ion comments ...?
One(!) TC comment can also be assigned to several files/folders, e.g. as follows:
  • Mark files
  • Menu "Files" - "Change Attributes..."
  • [✓] Change plugin attributes:
    Plugin Property Value
    tc comment Click on ">>"
  • Enter TC-comment, "F2 OK", OK (so you can also delete TC-comments by deleting the comment and pressing F2...)
  • The TC-comment was assigned to the files and the hidden file "descript.ion" was created in the same folder
  • Attention1: If a file already has a TC-comment and this file has been marked again for example with other files,
    and then a new/different TC-comment is entered, the previous TC comment is overwritten without a message!
  • Attention2: If you try to enter 2 or more TC comments via the "tc" plug-in, only the last TC comment will be assigned to the file(s)!
  • It is recommended to save the setting for TC comments: "F2 Load/save settings" -> "Save settings".
  • Don't forget to backup your 'descript.ion'-files ;-)
Stiltzkin
Member
Member
Posts: 182
Joined: 2004-09-10, 17:15 UTC

Re: Abou using the comment/descript.ion function from external script

Post by *Stiltzkin »

tuska wrote: 2021-05-20, 22:52 UTC
Stiltzkin wrote: 2021-05-20, 11:59 UTC ... or is there any fast way of settings descript.ion comments ...?
One(!) TC comment can also be assigned to several files/folders, e.g. as follows:
  • Mark files
  • Menu "Files" - "Change Attributes..."
  • [✓] Change plugin attributes:
    Plugin Property Value
    tc comment Click on ">>"
  • Enter TC-comment, "F2 OK", OK (so you can also delete TC-comments by deleting the comment and pressing F2...)
  • The TC-comment was assigned to the files and the hidden file "descript.ion" was created in the same folder
  • Attention1: If a file already has a TC-comment and this file has been marked again for example with other files,
    and then a new/different TC-comment is entered, the previous TC comment is overwritten without a message!
  • Attention2: If you try to enter 2 or more TC comments via the "tc" plug-in, only the last TC comment will be assigned to the file(s)!
  • It is recommended to save the setting for TC comments: "F2 Load/save settings" -> "Save settings".
  • Don't forget to backup your 'descript.ion'-files ;-)
jeah, i'm using that (with OPENATTRIBUTES from the buttonbar) since it was implemented (viewtopic.php?f=14&t=57060).

but i need a quick way to set a comment for a file/folder without gui interaction from any source (buttonbar, batch, powershell, python,...)
like tcc.exe's describe feature but with totalcmds feature set.
NotNull
Senior Member
Senior Member
Posts: 266
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: Abou using the comment/descript.ion function from external script

Post by *NotNull »

Stiltzkin wrote: 2021-05-20, 23:18 UTC like tcc.exe's describe feature but with totalcmds feature set.
I did a *very* quick test. Line breaks are a simple \n, like first\nsecond. Special characters are possible too.

This should work:

Code: Select all

tcc.exe /c describe "c:\path to\filename.txt" /D"some description\nsecond line%@char[0x04]%@char[0xC2]"

But all will depend on how you integrate it, because typing all this is more work than any alternative.
Stiltzkin
Member
Member
Posts: 182
Joined: 2004-09-10, 17:15 UTC

Re: Abou using the comment/descript.ion function from external script

Post by *Stiltzkin »

it works fine with ansi filenames, true.

i was testing it with "大 Test ✔ Tęśćt ✗ “Test” (Test) [Test].ext"
calling from AHK with:

Code: Select all

Run %ComSpec% /c "`"tcc.exe`" /c describe `"%FilePath%`" /D"%UserInput%`%@char[0x04]`%@char[0xC2]""
result with tcc.exe: (DESCRIPT.ION is ANSI)

Code: Select all

"? Test ? Tesct ? "Test" (Test) [Test].mp4" This is a comment¶
result with totalcmd gui: (descript.ion is UTF-8-BOM)

Code: Select all

"大 Test ✔ Tęśćt ✗ “Test” (Test) [Test].mp4" This is a comment
but it's a lot faster than any other implementation i've used so far.
NotNull
Senior Member
Senior Member
Posts: 266
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: Abou using the comment/descript.ion function from external script

Post by *NotNull »

Too bad it doesn't work with unicode ...

The (somewhat) good news: you can impove the speed even further as at the moment you start ahk, which starts cmd, which starts tcc.
Running cmd is not needed; you can start tcc directly from ahk.
Stiltzkin
Member
Member
Posts: 182
Joined: 2004-09-10, 17:15 UTC

Re: Abou using the comment/descript.ion function from external script

Post by *Stiltzkin »

ran into some parameter escaping problems without the start from cmd.

i found out that you can set the codepage if you create a "TCSTART.BTM" next to the tcc.exe file.
for example:

Code: Select all

CHCP 65001
then you get a UTF-8 DESCRIPT.ON with proper unicode characters from tcc.

but totalcmd doesn't recognize the DESCRIPT.ON until you change the UTF-8 DESCRIPT.ON to UTF8-BOM.
so jeah... :cry:
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Abou using the comment/descript.ion function from external script

Post by *hi5 »

Any reason you are not simply using AutoHotkey and the FileAppend option? Works with your "test file"
( I do it here viewtopic.php?f=6&t=73131 - using AHK to start another program to write something to a file is overly complicated if you ask me, just skip that step )
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
Stiltzkin
Member
Member
Posts: 182
Joined: 2004-09-10, 17:15 UTC

Re: Abou using the comment/descript.ion function from external script

Post by *Stiltzkin »

hi5 wrote: 2021-05-22, 08:12 UTC Any reason you are not simply using AutoHotkey and the FileAppend option? Works with your "test file"
jeah, i'm toying around with a lot of languages. java, python, powershell/batch, ahk, c#. so i don't really want to implement that function over and over again (i did a few times - but it's noticable slow).

tcc.exe is basically something the thing i wanted - a fast *.exe callable from every type of script. but it's not 100% compatible with the totalcmd-generated descript.ion files.
User avatar
Vochomurka
Power Member
Power Member
Posts: 814
Joined: 2005-09-14, 22:19 UTC
Location: Russia
Contact:

Re: About using the comment/descript.ion function from external script

Post by *Vochomurka »

I've written at least 4 scripts for PowerPro that handle TC comments.
Left column, chapter "File Comments (descript.ion)"
Single user license #329241
PowerPro scripts for Total Commander
Stiltzkin
Member
Member
Posts: 182
Joined: 2004-09-10, 17:15 UTC

Re: About using the comment/descript.ion function from external script

Post by *Stiltzkin »

Vochomurka wrote: 2021-05-23, 07:58 UTC I've written at least 4 scripts for PowerPro that handle TC comments.
Left column, chapter "File Comments (descript.ion)"
can i call them from another program/script to set comments? never worked with powerpro before.
Post Reply