I have an action that automatically renames the parent folder based on the metadata of the songs, using the $if function depending on if certain fields are empty. I tried using $trim but it didn't seem to work.
CATALOG and EVENT are custom metadata fields for the songs. It results in a neat folder name such as:
[ACCD2] Acclaims Raving X-Mas (1997) (flac)
However, my problem is that the second half of $if (the "no" else latter half, ",)") is inserting blank spaces in the filename if the metadata field is empty. This is inserting a space at the beginning of the folder name, and inserting a space after the year.
How can I avoid or automatically trim this while running this action? Ideally I don't want to run a separate "remove leading spaces" action after this, I want it all-in-one.
Could you please enclose your complete $if formula in code brackets (the 6. symbol in the mini editor toolbar of this discourse forum - or select your formula and press CTRL + E). This ensures that we can better see the backslashes and spaces and no character get lost.
You could save a number of complicated $IF()s if you used the square-bracket syntax for optional parts: ['['%catalog%']' ]%album% (%year%)[ '['%event%']'] (%_EXTENSION%)
If you had included the spaces in the statements instead of as separators between the statements so that the space would have been part of the output only if the condition returned a true result, then you would not have had the extra spaces in either case. This was a logic problem, no syntax problem.
I only find the square bracket syntax a little easier to read.