Menu

Conditional arguments

2018-07-04
2018-08-24
  • Sam Everitt

    Sam Everitt - 2018-07-04

    Hi, is it possible to rename a file to %{title} [%{subtitle}] only if %{subtitle} is not blank? I would like to avoid files names ending in "... [].mp3" when %{subtitle} is blank. Moreover, I would like to use the same syntax to use conditional arguements in the File/Import .. From Tags function as well. Is this possible via the GUI?

    I only have a very basic understanding of kid3-cli but happy use if it provides a solution. I imagine some combo of a 'filter' and 'import tags' would work but I dont know how to code it.

    Thanks
    Sam

     
  • Sam Everitt

    Sam Everitt - 2018-07-04

    Actuallhy, I think I have sorted this myself via the following steps:
    1) apply custom filter not(%{Subtitle} equals ""); and
    2) then apply whatever action I desire on the filtered sub-set of files.

    Let me know if there is a more simple / elegant solution.

    Cheers,
    Sam

     
  • Urs Fleisch

    Urs Fleisch - 2018-07-05

    One more simple than elegant solution would be to add a and expression which replaces " []" by "" in the string replacement table in the "Files" tab of the settings and enable "Automatically apply format" and "String replacement".

    "File/Import .. From Tags" will probably not help as it can only set tags and not the file name.

    The best solution would probably be to write a QML script which does it for the selected files and use it from a user action. If you know a bit of JavaScript and have a look at the example QML scripts, this should not be complicated.

     
  • Urs Fleisch

    Urs Fleisch - 2018-07-21

    I have added a new feature to solve this problem. You can now add strings in double quotes inside the curly braces, which will be inserted only if the corresponding value is not empty. The new section in the handbook is:

    It is possible to prepend and append strings to the replacement for a format code by adding them in double quotes inside the curly braces of a format code. These strings will only be put into the resulting string if the format code yields a nonempty value. For example, if the file name shall both contain the title and the subtitle, one could use %{title} [%{subtitle}] in the format string. But this would result in a string ending with [] if no subtitle frame exists for a file. In order to omit the brackets if no subtitle is present, %{title}%{" ["subtitle"]"} shall be used instead. This will omit the brackets, the leading space and the subtitle if not subtitle exists.

    You can test the new feature using the development version git20180721, which can be found in the development folder.

     
  • Urs Fleisch

    Urs Fleisch - 2018-08-24

    Fixed in version 3.6.2.

     
    😄
    1