Welcome Guest

Pages: 1
Multiple tests on beulk files
custa1200PostAugust 30, 2024, 12:17
Newbie
Posts: 12
Registered:
July 30, 2020, 02:33
Normal topicMultiple tests on beulk files

Hi I am trying to clean up my library so that if an album has a catalog number that I retrieve from Discogs I want to put it on the front of the album. But if there is no catalog number nothing should exit in front, and if I have flagged it as a compililation I also don't want the catalog to be added. I am trying to do with the following but I am getting unexpected (I know I am doing something wrong) behaviour when running across bulk files that meet one of more of the things I test against.


' Add Catalog to the Album·
Test if the Album field does not match regular expression "^\[
^\[" (Set test state)
if true
    Run action 'Add Catalog Number to Album' grouped
endif

' Removes Catalogs for Compilations in Album
Test if the Part of a Compilation field is >= "1" (Set test state)
if true
    Replace "^\[.*?\]\s*", case insensitive, regular expression in the Album field with ""
endif

' Removes empty Catalogs in Album
Test if the Album field starts with "[] " (Set test state)
if true
    Replace "^\[\]\s", case insensitive, regular expression in the Album field with ""
endif

 
2MR2PostAugust 30, 2024, 14:14
Avatar photo
Administrator
Posts: 2149
Registered:
August 23, 2012, 19:27
Normal topicMultiple tests on beulk files

I think the issue is with you determining which files have to be manipulated. You need a per file status for the test. Don't overthink it 🙂 The easiest thing to do is to remove an old sequence and simply add it back if required

1: ' Remove old [ ] sequence
2: Find first match for regular expression "^\[.*\]\s*" in field Album, replace with "" to field Album
3: ' On a per file basis test if Catalog Number is not empty and Part of a Compilation is false.
4: Test if the Catalog Number field is not empty (Set test state and Variable 1)
5: Test if the Part of a Compilation field is false (And test state and Variable 1)
6: ' The following is only executed for this tracks which meet the criteria
7: if Variable 1 is true
8: ' Get rid of extraneous spaces in Album and Catalog Number
9: Trim the Album and Catalog Number fields (SP) [Leading] [Trailing] [->SP]
10: Prepend "[\[Catalog Number]]·" to the Album field
11: endif

Line 2 removes any previously entered [ ] sequence at the start of Album
Line 4 tests if the Catalog Number field is not empty. It sets Variable 1 to true or false based on the result on a per file basis
Line 5 test is a track is not part of compilation. On a per file basis, the result is ANDed to Variable 1
Line 7 tests if Variable 1 is true. This if construct ensure that the following code is only executed in Variable 1 is true on a per track basis.
Line 9 gets rid of extraneous spaces in Album and Catalog Number ... just in case
Line 10 prepends the [Catalog Number] sequence to the Album field

It's can be hard to follow the text. I've uploaded the action to:

https://2manyrobots.com/actions/Prepend-Catalog-Number-to-Album.zip

I couldn't see what 'Add Catalog Number to Album' action does, but I assume the action above does the same.

2MR2PostAugust 30, 2024, 14:17
Avatar photo
Administrator
Posts: 2149
Registered:
August 23, 2012, 19:27
Normal topicMultiple tests on beulk files

If for some reason Catalog Number contained nothing but spaces, the tests would fail. To fix this unlikely issue move line 9 before line 4.

Pages: 1
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.026 seconds.