Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Compare two libraries' tagsets (... and overwrite)? (Read 316 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Compare two libraries' tagsets (... and overwrite)?

So I have a drive giving all warning signs about failure, and I disconnected it. My backup is a few weeks older and in the event of total failure, I will have some retagging to do, including some .zip purchases to unpack. No big deal.

Here is the thing, I have the old library with tags. I suppose I can export as .fpl, insert a newline for each "file://" and do a line-by-line diff, that would tell me quite a bit. (Wonder what the last three-quarters of the .fpl is, though.)

But can I do better? Like, sync back to files (those which have kept their name, obviously)?
For example, @Case , is it possible to use External Tags to sync back, or will I for example lose everything in my LargeFieldsConfig?
High Voltage socket-nose-avatar

Re: Compare two libraries' tagsets (... and overwrite)?

Reply #1
Doing it on SMP is trivial. You can easily write the entire library tags to json and restore it on the files matching paths and/or audio md5. (*)
It would be also trivial to write a plugin which can handle m-tags (not sure about external tags format) and use them to write tags to files too.

m-tags at least has an option to write tags to file and then write tags from file to tracks too. (create them, overwrite the current folder tracks with the backup folder tracks -thus maintaining the m-tags- and then write back m-tags to files).
External tags doesn't have that option according to its documentation.

EDIT: (*) Even better, you can compute the crc32 of all tracks' tags and compare them with the backup tracks (once a match has been found), therefore only needing to 'update' tags for those whose crc32 does not match (but path/audio md5 does). That has the bonus point that only a few number of tracks would be touched (date timestamps) and you can report the changes before applying them (have no idea if m-tags omits matching tags or rewrites them).

Re: Compare two libraries' tagsets (... and overwrite)?

Reply #2
If you download the latest files from this repository (not the lastest release), you will find a button named '.\buttons\buttons_save_tags.js'. That should do exactly what I described (it's in a rought state  since I simply mixed things I got here and there from my other tools to show a prototype).
https://github.com/regorxxx/Playlist-Tools-SMP

Tags are saved to .\AppData\Roaming\foobar2000\js_data\tags.json.
Function applies to current selection (so send entire library to a playlist first).
1. edit '.\main\save_tags.js' and change compareTags function with 'selItemsFolder' pointing to the root of your current library and 'toTagsFolder' pointing to the root of the library backup. For ex. I have my music at H:\Music\.... so  toTagsFolder= 'H:\\Music\\'. My backup is at J:\Backup\Music\... so selItemsFolder = 'J:\\Backup\\Music\\'. Tracks will be compared by path then and that part will be stripped, so the rest of the string should match. (*)
2. Load buttons on a SMP foobar panel.
3. Save tags of entire library selected on a playlist.
4. Load all backup tracks on another playlist and select them
5. Click on compare tags. Popups will appear, etc. and done. If there are tracks on Backup not found on current library (you changed paths at a later stage for ex.), a popup will appear listing them too.

(*) You could do some fancy matching here as prev. discussed. Like trying for audiomd5 first, and then path and subsong if no match found with the first check (mp3 for ex. don't have an audiomd5 tag). That way some files may have different paths but still be matched without collisions (and that's what I did with the Playlist Revive tool).

 

Re: Compare two libraries' tagsets (... and overwrite)?

Reply #3
Gosh ... will have a look at it :-)

I can always get the search down to the recently-modified files, save as .m3u, edit with H:\ replaced by J:\ as appropriate, load the new ones, kill dead items, and I will have two that match in paths.

(By the way, I missed that m-tags could commit to file - the then-absence of such a feature was the reason I never used it. foo_external_tags can commit to file, actually.)
High Voltage socket-nose-avatar

Re: Compare two libraries' tagsets (... and overwrite)?

Reply #4
Gosh ... will have a look at it :-)

I can always get the search down to the recently-modified files, save as .m3u, edit with H:\ replaced by J:\ as appropriate, load the new ones, kill dead items, and I will have two that match in paths.

(By the way, I missed that m-tags could commit to file - the then-absence of such a feature was the reason I never used it. foo_external_tags can commit to file, actually.)
The thing is the script needs to delete 'J:\' and ' H:\' parts, not replace them  ;) If you do what you wrote, you still have the same problem.
The script compares tags file (which has 'H') to selected tracks ('J'). Therefore you need to delete root paths internally when comparing paths or change the pats of the tags file. If you replace paths of selected tracks editing the playlist, you are simply pointing the files to the original tracks again. Thus comparing the tags file to the tracks they were originated from!

Either you adjust the script args with the right paths as written OR you edit the tag file (*.json):

- Omit step 1.
- Do step 2.
- Do step 3.
- Open tags.json file and replace all 'H:\' (current tracks path)  with  'J:\' (backup tracks path) and done.
- Do step 4.
- Do step 5.

 
SimplePortal 1.0.0 RC1 © 2008-2021