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

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Qoissi
Posts: 3
Joined: 21 Jul 2026 20:14

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

Post 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.
Last edited by Qoissi on 21 Jul 2026 23:00, edited 1 time in total.

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

Re: Importing tags and comments in tag.dat file

Post 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^^
One of my scripts helped you out? Please donate via Paypal

Qoissi
Posts: 3
Joined: 21 Jul 2026 20:14

Re: Importing tags and comments in tag.dat file

Post 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.

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

Re: Importing tags and comments in tag.dat file

Post 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()
One of my scripts helped you out? Please donate via Paypal

Qoissi
Posts: 3
Joined: 21 Jul 2026 20:14

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

Post 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).

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

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

Post by highend »

It should work by using that option:
Sorting is checked and corrected if necessary.
I guess it's just broken atm. Don?
One of my scripts helped you out? Please donate via Paypal

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

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

Post by admin »

It should work. Are you sure it's broken?

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

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

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

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

Post by admin »

Yep, confirmed. Fix comes. :tup:

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

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

Post by highend »

Confirmed with the latest beta...
One of my scripts helped you out? Please donate via Paypal

Post Reply