This is embarrassing because this should be simple. I can do this in Excel, SQL, etc. but in Picard, not a chance. All I want to do is strip this: 1039.86 kbps to “1039 kbps”. Anyone?
Try (untested code):
$set(_source,1039.86 kbps) $if($find(%_source%,.), $set(_target,$left(%_source%,$find(%_source%,.) kbps), $set(_target,%_source%) )
You could also do it a bit more efficiently using a
$rreplace() function like (untested code):
$set(_source,1039.86 kbps) $set(_target,$rreplace(%_source%,\(\\.\\d*\),)
That works great. Thanks
Can you explain this to me? This works. By trial and error and looking at samples it works but I don’t know why. I don’t understand why putting the $eq part and the number 1 makes a difference, but it does.
Can you break it down in English? LOL
I’m not sure what you’re trying to do here, but there are a couple of problems. First, your
$eq() will always return false because you are comparing “originaldate” to “”. I suspect that you meant to use
%originaldate% instead. Second, by entering the “1” within the first part of the
$if() statement, the evaluation will always be true. Third, you are setting the tag
originaldate to the value that it already holds.
So LOL now you know why I needed to have someone explain this. Back to the drawing board.
I do have trouble with the conditions. I struggle with it for some reason here. I don’t seem to have that problem with SQL or Excel.
I’m trying to figure out this next task. Maybe you have some ideas on if this is possible.
IF %_bitrate% falls in the range of:
- 128-159 then Quality is Fair
- 160-199 then Quality is Good
- 200-480 then Quality is Very Good
- 481-2000 then Quality is Excellent
Perhaps something like:
$set(Quality,Really Bad)$noop( This is the default value ) $if($gte(%_bitrate%,128),$set(Quality,Fair) $if($gte(%_bitrate%,160),$set(Quality,Good) $if($gte(%_bitrate%,200),$set(Quality,Very Good) $if($gte(%_bitrate%,481),$set(Quality,Excellent)
What does the “$noop” do? Comment?
It actually does nothing at all. Good for entering comments in the code. See the documentation for more information.
hi there, where would this go? scripts or rename folder?
Also is this for mp3 tracks or can this work with lossless files?
It sort of depends on what you’re doing with it. If you’re saving the information as metadata into the file, then it will need to go in a tagging script, whereas if you’re using it as part of the file naming, then it would go in the file naming script. If you’re using it to set the value of a tag, note that the
%_bitrate% information will only be available once a file has been matched to a track or if the tagging script is run against a file. See the Note on the File Variables page in the Picard User Guide for more information.
I believe that it works with both, but I haven’t tested that so I could be mistaken.
thank you I was just adding it to the scripts page but for cd tracks it comes out as very poor, when they should come out as very good and anything above cd quality should come out as excellent
any thoughts please?
The script is likely being run when the album information is retrieved from MusicBrainz, which occurs before the files are matched to the tracks. What you need to do is match the files to the tracks and then re-run the script manually. See the last paragraph under the Tagging Scripts of the docs for more information.