So, I was doing some much-needed Library cleanup last night (for hours and hours), and I came across a situation that I'm not sure how to fix easily, and wondered if anyone had any tips. I think there's a clever way to do this, but I can't remember how...
If I have a bunch of files that have the [Name] field filled like this:
Track # - Song Title
The actual [Track #] field is blank, and I don't want that extra information in the [Name] field (I want to remove everything at the beginning, after copying the number over to the appropriate field). The problem is that, in the cases I was hitting regularly last night:
1. These were audiobooks, so the track number part of the [Name] field actually went to three digits, but didn't start out as three digits. They looked like "1 - Some section title" at the beginning, and "386 - Some section title" at the end of the list of files.
2. The actual filenames weren't easily parse-able, so it wasn't easy to use the Fill Properties from Filename tool without hosing a bunch of existing data in the files. The data in the [Name] field came from ID3 tags in the files, not from auto-parsing the filenames.
3. The files were out of order. I suppose I could have sorted the order, and then just done =Counter() in the [Track #] field, but the problem with that is that it doesn't let me make sure I don't have any duplicates or missing tracks. When you have 300+ files, it isn't easy to just verify this visually.
I want to parse the [Name] field and extract the [Track #], remove the " - ", and leave only the "Song Title" in the [Name] field.
This turned out to be annoyingly difficult. This is how I did it:
1. Use =ListItem() in the [Track #] field, looking at list item 1 in the [Name] field, to fill the track numbers properly. This filled [Track #] and left [Name] untouched.
2. Use =ListItem() in the [Name] field, looking for the second list item. This removed the track numbers from the [Name] field properly, but it left a leading space for each one (since it wasn't possible to use " - " as the delimiter, since spaces are ignored in Expressions).
3. Use =Clean() on the [Name] field to nix that leading space.
4. A side-order of =FixCase() most of the time.
This was annoyingly difficult, though certainly not impossible. It took 3-4 "steps" to fix it each time, and inevitably once or twice I'd forget to type the = sign, and would overwrite all of the tracks in that particular field (requiring Control-Z try again).
It isn't the end of the world, but the whole time I felt like there should be some sort of Split The Existing Field ala Fill Properties from Filename function. I'm sure if I was a smarter man, I could use a RegEx to do it, but I'm not a smarter man.
Is there some existing function that would have done this better? I searched through the Wiki and did a few forum searches, but then gave up after finding nothing and knowing how to solve it myself via the clunky 4 step process above.