Search & Replace Script

If you need help on how to use the program
Post Reply
figu
Posts: 2
Joined: 2020-01-17 11:33:05

Search & Replace Script

Post 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.
antp
Site Admin
Posts: 9642
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: Search & Replace Script

Post 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 ;)
figu
Posts: 2
Joined: 2020-01-17 11:33:05

Re: Search & Replace Script

Post 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.'
antp
Site Admin
Posts: 9642
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: Search & Replace Script

Post by antp »

here is the conditon:

Code: Select all

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