I am trying to create an action that stores disc number and total discs as a single string, but only when there is more than 1 disc. In cases where there is only 1 disc then both the total discs and disc number tags should be deleted.
I've tried to break this down into logical steps to cover most eventualities (such as either of the fields being blank), but I'm new and not very good at this sort of thing, so therefore there may be a more effective set of steps to take in order to achieve this (in other words, combining certain steps into a single command where they don't need to be performed separately, or changing the order of steps to prevent any unintended consequences).
I'm thinking about doing it the following way:
1. If the TOTALDISCS field is empty and the DISCNUMBER field is 1 (regardless of any leading zeros) then delete the DISCNUMBER field. This will mean that there will be neither a DISCNUMBER or a TOTALDISCS tag any more.
2. If the DISCNUMBER field is empty and the TOTALDISCS field is 1 (regardless of any leading zeros) then delete the TOTALDISCS field. This will mean that there will be neither a DISCNUMBER or a TOTALDISCS tag any more.
3. If the TOTALDISCS field and the DISCNUMBER field are both 1 (regardless of leading zeros) then delete both TOTALDISCS and DISCNUMBER tags.
4. If the DISCNUMBER value exceeds the TOTALDISCS value (strip any leading zeros) then delete the TOTALDISCS tag so that only the DISCNUMBER tag remains with no leading zeros.
5. If the TOTALDISCS value is the same as or exceeds the DISCNUMBER value then then merge the contents of DISCNUMBER and TOTALDISCS into a single string separated by a forward slash and stored in the DISCNUMBER field (with all leading zeros removed) and then delete the TOTALDISCS tag. This will mean only the DISCNUMBER tag remains, and it will have a value in the format x/y.
I'm assuming that there is no need to state "greater than 1" in step 5 because any tags with value 1 would have already been deleted.
I think I've covered everything, but any advice on the best way to achieve this would be gratefully received.