Page 1 of 1

[Solved] Importing tags and comments in tag.dat file

Posted: 21 Jul 2026 20:32
by Qoissi
Hello,

I'm new to XY and would like to migrate to its very good tagging system. Up to now I put all my meta data (tags, rating, comments...) in another software.
So far I could:
- Export all those meta data in a text file.
- Thanks to a little Python script transform this text file into a format compatible with the Data: section of the tag.dat file.
This resulted into +1000 lines.

But when I copy those lines into the tag.dat file and save it (using UTF-16 LE encoding) most of the entries are ignored by XY.
It seems very linked to the line ordering. I could read that all Data: lines must be *binary* sorted, which I tried to do, but even when I do more than half of the entries are still ignored and I'm lost. I couldn't find any information about this in the documentation.

Any help on how to sort those lines properly will be much appreciated.

Thanks a lot.

Re: Importing tags and comments in tag.dat file

Posted: 21 Jul 2026 20:53
by highend
Select all your tagged entries (all lines after the Data:), copy them into the clipboard and then execute this XY script command:
copytext formatlist(<clp>, "ec", <crlf>);

Afterwards you can just paste the clipboard content over all the selected lines and save the file again.

Do this while XY is _not_ open^^

Re: Importing tags and comments in tag.dat file

Posted: 21 Jul 2026 21:43
by Qoissi
Thanks for your reply!
Still, the result is not perfect and I think I understood the pattern: it seems all my files are now correctly tagged, but not most of the folders.
It occurs when the folder is listed *after* the files it contains, and it can happen a lot with this sorting method. I could check that if I move manually the folder line before the lines listing its files, it is correctly recognized by XY. Would you have any magic way to make that automatically?
Thanks again.

Re: Importing tags and comments in tag.dat file

Posted: 21 Jul 2026 22:14
by highend
Try this python script (pyperclip must be installed):

Code: Select all

import pyperclip

def sort_key(line: str):
    path = line.split("|", 1)[0]
    return path.split("\\")

def main():
    text = pyperclip.paste()
    lines = [line for line in text.splitlines() if line.strip()]
    sorted_lines = sorted(lines, key=sort_key)
    result = "\n".join(sorted_lines)
    pyperclip.copy(result)

if __name__ == "__main__":
    main()

Re: [Solved] Importing tags and comments in tag.dat file

Posted: 21 Jul 2026 23:03
by Qoissi
Thank you so much! Worked perfectly.

As last comment, maybe my case is isolated but I would have loved a more intuitive import method for this. Or at least, a simple built-in feature to sort the lines properly to be well recognized (e.g. as part of the "Database Check..." process).

Re: [Solved] Importing tags and comments in tag.dat file

Posted: 21 Jul 2026 23:07
by highend
It should work by using that option:
Sorting is checked and corrected if necessary.
I guess it's just broken atm. Don?

Re: [Solved] Importing tags and comments in tag.dat file

Posted: 22 Jul 2026 09:28
by admin
It should work. Are you sure it's broken?

Re: [Solved] Importing tags and comments in tag.dat file

Posted: 22 Jul 2026 09:41
by highend
Tested on XY x32 current beta

I have these 3 lines in a test tag.dat file:

Code: Select all

D:\Users\Highend\Downloads|0|a|||||||||||||||||
D:\Users\Highend\Downloads\disable_updates.bat|0|b|||||||||||||||||
D:\Users\Highend\Downloads\hash.exe|0|c|||||||||||||||||
They are working fine.

Now I quit XY, and edit the tag lines to this:

Code: Select all

D:\Users\Highend\Downloads\hash.exe|0|c|||||||||||||||||
D:\Users\Highend\Downloads\disable_updates.bat|0|b|||||||||||||||||
D:\Users\Highend\Downloads|0|a|||||||||||||||||
XY restarted, now only the disable_updates.bat file shows the "b" tag

When I do the Database Check... and accept everything with "OK" for all dialogs,
nothing changes.

File - Settings Special - Save Tags doesn't get a * in front of it; saving settings doesn't do anything to the tag.dat file either.

So if Database Check... should really fix wrongly sorted tagged items in the database, it doesn’t work...

Re: [Solved] Importing tags and comments in tag.dat file

Posted: 22 Jul 2026 11:24
by admin
Yep, confirmed. Fix comes. :tup:

Re: [Solved] Importing tags and comments in tag.dat file

Posted: 22 Jul 2026 14:02
by highend
Confirmed with the latest beta...