handling files commnents in descript.ion subsidiary files

Features wanted...
admin
Site Admin
Posts: 65389
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

Leopoldus wrote:I think, sofware is to serve a man, not to teach him a life philosophy :)
Why not kill two birds with one stone? :)

Do you know that file commenting is built into Win2K/XP? (see File Properties dialog...)

Leopoldus
Posts: 237
Joined: 24 Jun 2004 10:58

Post by Leopoldus »

Yes, of course, I know it.

But
Once more, many modern file managers (Total Commander etc) and download managers (ReGet etc.) work with descript.ion subsidiary files. BTW, either TC or ReGet are programms for advanced users, who know how to use their system options optimally, e.g. filenames.
So in regards of compatibility with othe application it would not be a solution.

Another, and more serious, problem, that when using this properties deialog commenting feature in Wndows XP, it changes the "time modified" attribute of the file every time the file being commented (please regard, that you may need to change those comments many times). So you loose one of important data sourses about the file.
There are more reasons here. For example, comments in descript.ion are an usual text and you can use them for searhing the file e.g. via TrackerV . And you can see and editor this text in viewer/editor you choose itself, not in Windows' properties dialog. And you can see these comments when you point a cursor over a file (a tooltip), so you do not need to open every file separately in "properties" dialog. And.....
BTW that Ghisler has introdused descript.on files handilng in his Total Commander when Windows XP has already this option comment files, so one can conclude, that according Ghisler and TC's users opinion this Windows XP option does not answer users' need of commenting files (and it does not really :().

Native2904
Posts: 64
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: handling files commnents in descript.ion subsidiary files

Post by Native2904 »

Because XY uses its own comments file, and I had put so much time into TC to comment all my apps with descriptions (what kind, where to get them, tutorial URL), I searched for a way to import these comments to XY; to create a custom column for this folder with the Comment column.

I've been using computers since the C64, but I don't have essential skills in programming or scripting.

So i ask Chatgpt to write a script with what I can import comments from the descript.ion to XY tag.dat:

Code: Select all

// Pfad zur descript.ion-Datei (anpassen falls nötig)
$descFile = "<curpath>\descript.ion";

// Datei Zeile für Zeile einlesen
$text = readfile($descFile);
$lines = tokenize($text, "<crlf>");

// Jede Zeile enthält: Dateiname Kommentar
foreach($line, $lines) {
  // Dateiname und Kommentar trennen
  // Hinweis: Wenn der Dateiname Leerzeichen enthält, ist er in Anführungszeichen
  if (regexmatches($line, '^"(.+?)"\s+(.+)$')) {
    $filename = regexreplace($line, '^"(.+?)"\s+(.+)$', '$1');
    $comment  = regexreplace($line, '^"(.+?)"\s+(.+)$', '$2');
  } else {
    // Kein Zitat → einfacher Dateiname
    $filename = gettoken($line, 1, ' ');
    $comment  = trim(substr($line, strlen($filename)));
  }

  // Kompletter Pfad zur Datei
  $filepath = "<curpath>\$filename";

  // Nur wenn Datei existiert
  if (exists($filepath) == 1) {
    // Kommentar als XY-Kommentar speichern
    tag "$comment", "$filepath", 2, 0;
  }
}

// Speichern der tag.dat
#195; // save settings
text "Import abgeschlossen.", 64;
But the only thing that happened is that the script showed a shell. I'm asking ChatGPT a lot, but I believe the AI has no knowledge of XY.... If someone here sees an error in the script from ChatGPT, or knows a way to import this descript.ion to XY, that would be great!
HGWunjjF5S.png
HGWunjjF5S.png (10.07 KiB) Viewed 4452 times
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

highend
Posts: 14671
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: handling files commnents in descript.ion subsidiary files

Post by highend »

Multi-line Scripts and Multi-Scripts
A script can have more than one line (multi-line script), and a script resource can have more than one script (multi-script). There is one important formatting rule for multi-line scripts:
In a multi-line script all lines apart from the first line have to be indented by at least one space.
And ChatGPT produces bullshit, e.g. tokenize(). There isn't such a command...

Apart from that: viewtopic.php?t=9145

If that doesn't work anymore, fix it (I'm not a TC user)
One of my scripts helped you out? Please donate via Paypal

Native2904
Posts: 64
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: handling files commnents in descript.ion subsidiary files

Post by Native2904 »

2 highend

I'm trying out your script, but it's not really helpful.
Still, I'm happy without this Comment Column – XY is XY, and TC is TC.
⇉ You shouldn't compare apples to oranges.

Thank you very much for your help!
It's only a small detail, but it's about better comprehension.
TOTALCMD64_lJYOI1UT8Q.png
TOTALCMD64_lJYOI1UT8Q.png (65.95 KiB) Viewed 4434 times
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

highend
Posts: 14671
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: handling files commnents in descript.ion subsidiary files

Post by highend »

Why don't you just provide a few current (zipped) descript.ion files?...
One of my scripts helped you out? Please donate via Paypal

Native2904
Posts: 64
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: handling files commnents in descript.ion subsidiary files

Post by Native2904 »

This morning, I tried to adapt your script (with AI - step by step) to my desktop environment, but due to my limited scripting skills, it fails to detect the descript.ion file in the path – even though it’s definitely there.


Code: Select all

  // Initialize    
    $tabSearchOption = getkey("SearchResultsTab", "General");
    // =0 -> Current tab
    // =1|2|3 -> New tab
	// Verwende das aktuelle Verzeichnis
    $searchDir = <curpath>;
	
	// Schritt 3: Prüfen, ob eine descript.ion-Datei im aktuellen Verzeichnis existiert
    $descriptFile = "$searchDir\descript.ion";
    if (exists($descriptFile) != 1) {
       msg "Im aktuellen Verzeichnis wurde keine Datei 'descript.ion' gefunden. Das Script wird beendet.";
       end true;
}

    // Setze den Pfad der zu verarbeitenden Datei
    $foundFiles = $descriptFile;
	
	// Lies die Datei ein und bereite Inhalt auf
    $content = readfile($foundFiles);
    $content = replacelist($content, "<crlf>|<lf>|<cr>", "<crlf>", "<crlf>"); // vereinheitliche Zeilenenden
    $content = regexreplace($content, "[\x00-\x1F]", ""); // Steuerzeichen entfernen

    // Bereite für späteren Export vor
    $newXYTags = "";
    $tagsPerFile = "";

    // Verarbeite jede Zeile
    foreach($line, $content, "<crlf>") {

        // Ignoriere leere Zeilen
        if (trim($line) == "") { continue; }

        // Prüfe, ob Name in Anführungszeichen
        if (strpos($line, chr(34)) == 0) {
        $name = trim(regexmatches($line, '^".*?"', ""), '"');
        $comment = trim(regexreplace($line, '^".*?"\s*', ""));
    } else {
        $name = trim(regexmatches($line, '^[^\s]+', ""));
        $comment = trim(regexreplace($line, '^[^\s]+\s*', ""));
    }

       // Konstruiere vollständigen Pfad zur Datei
       $fullPath = $searchDir . "\" . $name;

       // Optional: prüfen, ob Datei existiert
       // if (!(exists($fullPath) == 1)) { continue; }

       // Erzeuge Tag-Eintrag
       $tagEntry = $fullPath . "|0|||||||" . $comment . "<crlf>";
       $tagsPerFile = $tagsPerFile . $tagEntry;
    }

    // Sortiere und entferne Duplikate/leere Einträge
    $newXYTags = formatlist($tagsPerFile, "ec", "<crlf>");
	
	// Ausgabe oder Weiterverarbeitung (z.B. speichern)
    msg "Folgende Tags wurden generiert:<crlf><crlf>" + $newXYTags;
    
	// Backup der bestehenden tag.dat (automatisch mit Datum/Zeit)
    copyas "tag_<datem yyyy-mm-dd_hh-nn-ss>.dat", "<xydata>", "<xydata>\\tag.dat";

    // tag.dat einlesen und Kopfbereich extrahieren (alles bis 'Data:\r\n')
    $curTagFileLeading = regexmatches(readfile("<xydata>\\tag.dat"), ".*?[\s\S]*Data:\r\n");

    // Neue tag.dat zusammensetzen
    $newTagDat = $curTagFileLeading . $newXYTags;

    // tag.dat schreiben
    writefile("<xydata>\\tag.dat", $newTagDat);

    msg "Die Tags wurden erfolgreich in tag.dat gespeichert.<br><br>Bitte starte XYplorer neu, um die Änderungen zu sehen.";

    
C:\Users\Home\Apps
descript.zip
(2.22 KiB) Downloaded 140 times
C:\tcmd\Tools
descript.zip
(1.65 KiB) Downloaded 133 times
Last edited by Native2904 on 19 Jun 2025 15:40, edited 1 time in total.
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

Native2904
Posts: 64
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: handling files commnents in descript.ion subsidiary files

Post by Native2904 »

I believe that the generated Comments aren't suitable for XY, because, i see in the tag.dat are some Information about the descript.ion.
swirVM5aHO.png
swirVM5aHO.png (434.64 KiB) Viewed 4343 times
Then the cause lies somewhere else.
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

highend
Posts: 14671
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: handling files commnents in descript.ion subsidiary files

Post by highend »

- Every line of a descript.ion file represents the name of a file / folder in the same directory as the .ion file up to the first space in the line and everything after the first space is the comment, correct?
- All names that are inside double quotes need their double quote removed to represent the real name (in this case the name is not just up to the first space but everything inside the double quotes)?
One of my scripts helped you out? Please donate via Paypal

Native2904
Posts: 64
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: handling files commnents in descript.ion subsidiary files

Post by Native2904 »

Absolutely correct.
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

highend
Posts: 14671
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: handling files commnents in descript.ion subsidiary files

Post by highend »

v0.5 is available here:
viewtopic.php?p=81473#p81473

I would delete your tag.dat file first (make a backup copy before doing that)...
One of my scripts helped you out? Please donate via Paypal

Native2904
Posts: 64
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: handling files commnents in descript.ion subsidiary files

Post by Native2904 »

Merci beaucoup !
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

highend
Posts: 14671
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: handling files commnents in descript.ion subsidiary files

Post by highend »

No problem and thanks for the donation.

The descript.ion file format is crap, why the hell isn't UTF-8 used for it?...
So if you enter any unicode characters in them, you're on your own ;(

Btw, the idea itself is a good one but I don't want to tag files only for this kind of stuff so I'm using a CEA script in conjunction with a special cc column.
The CEA script reads an existing descript.ion file, puts its content into permanent variable and shows or hides the belonging cc column for it.
The cc column reads from that permanent variable and matches the file / folder to the comment from the belonging line...
One of my scripts helped you out? Please donate via Paypal

SpiroC
Posts: 15
Joined: 01 Dec 2017 23:20

Re: handling files commnents in descript.ion subsidiary files

Post by SpiroC »

A little late in this conversation sorry. Last time I updated XYplorer there wasn't even a 64-bit version yet!! When I went down the file description rabbit hole, I wasn't happy with anything that wasn't cross platrform so I quickly gave up on MS options. I ended up writing my own XY scripts with not just descriptive .txt files but 2 useful variants also. I have been running these now for years (like 5 years+). If I right click on a custom icon in the XY toolbar, here are my file-generation-script choices. They are all text files, created using the current contents of the clipboard:

New URL [clipboard] copy base
New URL [clipboard] parent folder
New txt file [clipboard] copy base
New txt file [clipboard] parent folder
New filelinks.txt file [clipboard]

"New URL": The first 2 create windows.url file, so I can copy any url I want, usually the download link of a file. eg, I download a file, but I want to capture the url (so I can keep a record of where I got it or a quick way to get back to the download page). I copy the url from the address bar and run one of the first 2 scripts. eg I end up with new-download.zip and new-download.url right next to it. If the filename is too generic and I don't want to change it (for future reference when I am back on the same website), I make the parent foldername meaningful and use the second script. This was I end up with eg generic-name.zip and generic-name_2026-05-15.url where I have named the parent folder generic-name_2026-05-15.

"New txt file": creates a .txt file containing the clipboard contents, with .txt filename either selected file basename + .txt, or parent foldername + .txt. These are the 2 that replace descript.ion files. You write a description in your favorite text editor and use one of these to place it right next to your download with the same basename. I have often thought it might have been better to append .txt to the existing name. eg download.zip, and download-zip.txt. I will get around to trying it one day.

"New filelinks.txt file": I use this with urls of large downloads files. I click this first with a large download url in the clipboard, and then when I middle click on a (different, custom) icon in the toolbar, it launches aria2c console downloader in a cmd window which picks up filelinks.txt in the current folder and downloads the file using lots of threads and pieces in a very nice aria2c way.

Post Reply