Page 1 of 1

Search & Replace Script

Posted: 2020-01-17 11:40:13
by figu
Good morning.
I need a search and replace script, in particular I want to change the text of the field "source" to a different one without having to do it manually.
Thank you very much.

Re: Search & Replace Script

Posted: 2020-01-17 13:03:36
by antp
Hi,
There is a script name "Update all fields" that provides various options for that.
Otherwise a very basic script like this will apply the same value to all selected movies:

Code: Select all

Program NewScript;
begin
  SetField(fieldSource, 'new text');
end.
You can find in the Help of the program the list of the field names.
If you want to do a real search/replace of the whole field (i.e. check the existing value and replace only if it matches) :

Code: Select all

Program NewScript;
begin
  if GetField(fieldSource) = 'old text' then
  begin
    SetField(fieldSource, 'new text');
  end;
end.
Maybe do a backup of your catalog before experimenting that ;)

Re: Search & Replace Script

Posted: 2020-01-18 18:26:56
by figu
Thank you very much for your quick response.
Would it be possible to change the value of a field if two conditions are met?

For example:

Current value of the "Source" field: 'HDD 5T'
New value: 'HDD 3'

Conditions:
Field "Source" = 'HDD 5T'
Field "Media label" includes word 'SAGA'

Thank you in advance.'

Re: Search & Replace Script

Posted: 2020-01-19 09:17:55
by antp
here is the conditon:

Code: Select all

if (GetField(fieldSource) = 'HDD5T') and (Pos('SAGA', GetField(fieldMedia)) > 0) then