request: script to replace items

Use this forum for everything concerning script usage
Post Reply
Wurlitzer
Newbie
Newbie
Posts: 38
Joined: Mon Sep 13, 2010 11:09 am

request: script to replace items

Post by Wurlitzer »

Hi,

is it possible to recplace items in a specific data field by script?
My problem: in several data fields, e.g. genre, I used "," as separator. Several music managing programs (e.g. Helium, Musicbee) use ";" as separator. What to do to replace "," with ";" in these data fields?

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

Re: request: script to replace items

Post by jtclipper »

You could use a replacement matrix for that but here is a simple script that would do that.

Code: Select all

program replace_sep;

begin

  if not tg_Init then exit; // no rows get out

  repeat

    tg_setField( 'Genre', AnsiReplaceText( tg_getField( 'Genre' ), ',', ';' ) );
    tg_setField( 'Tones', AnsiReplaceText( tg_getField( 'Tones' ), ',', ';' ) );
    tg_setField( 'Styles', AnsiReplaceText( tg_getField( 'Styles' ), ',', ';' ) );
    tg_setField( 'Mood', AnsiReplaceText( tg_getField( 'Mood' ), ',', ';' ) );
    tg_setField( 'Situation', AnsiReplaceText( tg_getField( 'Situation' ), ',', ';' ) );

  until not tg_Skip;

end.
Moreover you can now easily modify the online amg script to use ; as a separator, At line 11

Code: Select all

const LIST_SEP = ','; 
you can change comma to a semicolon there

Wurlitzer
Newbie
Newbie
Posts: 38
Joined: Mon Sep 13, 2010 11:09 am

Re: request: script to replace items

Post by Wurlitzer »

Thank you jtclipper,

this is amazing and will help me lot.

Post Reply