scv script doesn't work in rename format string

Use this forum for everything concerning script usage
Post Reply
hopalongrock
Sr. Member
Sr. Member
Posts: 289
Joined: Wed Sep 15, 2010 1:38 pm

scv script doesn't work in rename format string

Post by hopalongrock »

I created a scv script "RRip.scv":

// RRip.scv
// %@RRip%

begin
if pos(uppercase(gTag.comment),'CD,RIP')>0 then
var_result(gtag.track + ' - Rip')
else
var_result(gtag.track)
end.

I try to append ' - Rip' after the track when it's needed.

Unfortunately I can't find how to compile, so I do not know whether it's good or not.
I copied it to an sct file, compiled it, it looks good, only var_result is unknown.

I put it in rename format string as
%A% - %T% - %L% - %@RRip%
instead of %A% - %T% - %L% - %R%

However the filename contains %@RRip% as literal
3 Honeydrops - Honey Drop - Goin' Wild! Music City Rock 'N' Roll - %@rrip%.mp3
Maybe %@RRip% can't be used in a rename format string, maybe "script aware" in the help says that it can be used only in scripts, but it would be very useful here.

I wouldn't like to use for this an extra field containing rip or empty, there is too many file.

Now I do this changing the rename script
from %A% - %T% - %L% - %R%
to %A% - %T% - %L% - %R% - Rip
according to the comment field,
and use filters to scan for errors.

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: scv script doesn't work in rename format string

Post by jtclipper »

The variable script format must use the filename+extension like so :

Code: Select all

%@RRip.scv%
(I was thinking of dropping the extension requirement but I kept it to be more obvious that this is a script file)

You can use CTRL_F9 to test if it compiles, but you should use the following regarding the Pos function to get the desired result, unless your comment only contains those words which will make your original script work fine

Code: Select all

begin
  if (pos( 'CD', uppercase(gTag.comment) ) > 0) or  (pos( 'RIP', uppercase(gTag.comment) ) > 0)  then
     var_result(gtag.track + ' - Rip')
  else
     var_result(gtag.track)
end.

hopalongrock
Sr. Member
Sr. Member
Posts: 289
Joined: Wed Sep 15, 2010 1:38 pm

Re: scv script doesn't work in rename format string

Post by hopalongrock »

Thanks, It's fantastic for me ! Now the script and the rename works fine !!!

However, it looks if change a scv script, TGF must be restarted for the change to happen.
Is this true or normal ?

.....

TGF trims the fields for a long time, probably because the "Trim variables (%...%)" is checked,
although it happens for example for artist, comment, etc, when there is no % variable involved - value is changed in the grid.
It's usually good for me, although in case of comment, etc it would be better, if after an update and rescan I would see the original content.
Because the comment field is disabled in all of my work flow tasks, I think that the change is not justified.
Perhaps it would be best to do a trim/don't trim setting in replacement matrix to be able to specify the fields, where somebody wants/doesn't want the trim, similarly to the ignore options.

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: scv script doesn't work in rename format string

Post by jtclipper »

If you create/edit the variable scripts from the options menu then they recompile and are ready without exiting the program.

The trim option in the edit section is also in effect and will trim all tag fields upon read when it is selected

hopalongrock
Sr. Member
Sr. Member
Posts: 289
Joined: Wed Sep 15, 2010 1:38 pm

Re: scv script doesn't work in rename format string

Post by hopalongrock »

jtclipper wrote:If you create/edit the variable scripts from the options menu then they recompile and are ready without exiting the program.
I used Edit button - Script menu (only shows sct files) - manage scripts - file - new/open - edit - compile[if I compile, finishes with error], save . If I do here, I have to restart TGF.

Oops ! At last I thought and went through all the settings in Options and found in "Formatting - Variables - User" my script: R-Rip.scv, then "select it - manage - edit [- compile] - save", rescan, and it works fine. And I can define the order of the execution of the variable scripts.

It's great. I don't know, maybe you could write in the help / %variables% / user (scv) variables paragraph, where have to edit/compile the scv scripts.
jtclipper wrote:The trim option in the edit section is also in effect and will trim all tag fields upon read when it is selected
Oh, yes, this is it. I only thought, it would be useful sometimes to miss out some fields from the trim.
I think I would try to disable the option, and use the trim function in a replacement matrix - hopefully trim does left and right trim.

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: scv script doesn't work in rename format string

Post by jtclipper »

Yes the help file will get a small update regarding those scripts since they use a new function and have a few other restrictions also (like they don't accept commands to display dialogs )

I could add another task in the work flow to 'Trim' fields but I'm not sure if it is really needed, since I have in mind to introduce event scripts (triggers before/after read/save/delete/rename) in the next release.

hopalongrock
Sr. Member
Sr. Member
Posts: 289
Joined: Wed Sep 15, 2010 1:38 pm

Re: scv script doesn't work in rename format string

Post by hopalongrock »

jtclipper wrote:Yes the help file will get a small update regarding those scripts since they use a new function and have a few other restrictions also (like they don't accept commands to display dialogs )
I little...BIG help never hurts.
jtclipper wrote:I could add another task in the work flow to 'Trim' fields
It would be great, I think. Now I don't know, that the trim by the options is before or after the work flow tasks.
jtclipper wrote:but I'm not sure if it is really needed, since I have in mind to introduce event scripts (triggers before/after read/save/delete/rename) in the next release.
This is what I wait for, automatically executed user scripts.

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: scv script doesn't work in rename format string

Post by jtclipper »

Trim of the tag fields happens before anything else.
Event scripts will solve various advanced cases will introduce those in 0.89 beta

hopalongrock
Sr. Member
Sr. Member
Posts: 289
Joined: Wed Sep 15, 2010 1:38 pm

Re: scv script doesn't work in rename format string

Post by hopalongrock »

Thank you.

Post Reply