Kid3-cli: Set tag selection without failing

So I currently have a script where I want to copy some metadata from one music file to another:

# Copy almost all tag 2 fields from the from file to the to file
kid3-cli -c "select $fromFile" -c "set '*.selected' 1" -c "set 'acoustid fingerprint.selected' 0" -c "set 'acoustid id.selected' 0" -c "set 'isrc.selected' 0" -c "set 'musicbrainz album id.selected' 0" -c "set 'musicbrainz album status.selected' 0" -c "set 'musicbrainz album type.selected' 0" -c "set 'musicbrainz work id.selected' 0" -c "copy" -c "select $toFile" -c "paste"

$fromFile and $toFile are just paths to the music files.

The issue I have is that if I try to set say isrc.selected to 0 but it doesn’t exist, the command will fail and the subsequent commands won’t go though.

Is there any easy way to just deselect a tag if it exists and then skip it if it doesn’t exist? I am trying to avoid doing a for loop through multiple tags and checking them and storing them in a variable to check if they’re empty and then setting the selection to 0 if it exists.

You can use an empty string instead of 0, then the error will be ignored.

# Copy almost all tag 2 fields from the from file to the to file
kid3-cli -c "select $fromFile" -c "set '*.selected' 1" -c "set 'acoustid fingerprint.selected' ''" -c "set 'acoustid id.selected' ''" -c "set 'isrc.selected' ''" -c "set 'musicbrainz album id.selected' ''" -c "set 'musicbrainz album status.selected' ''" -c "set 'musicbrainz album type.selected' ''" -c "set 'musicbrainz work id.selected' ''" -c "copy" -c "select $toFile" -c "paste"
1 Like

It works, thank you!