Page 1 of 1

Add random number to filename?

Posted: Fri Feb 08, 2013 1:08 pm
by Thom
Hello,

I´ve a question ;)

I have an USB player that not supports an random function and plays the music only in an alphabetic order, not very handy of course. Is it possible that the program add´s an random number in front of the filename?

For example;
Depeche Mode - Just Can't Get Enough.mp3 » [035] Depeche Mode - Just Can't Get Enough.mp3
Depeche Mode - People Are People.mp3 » [050] Depeche Mode - People Are People.mp3


Thx if anyone can help me!

Greets,
Thom

Re: Add random number to filename?

Posted: Fri Feb 08, 2013 4:05 pm
by jtclipper
There is no random function available in the script engine but I will add a reference to it.
So this will not work until I upload the next beta update, you will have to wait a few days.

Code: Select all

program RenameRnd;
begin
  if not tg_Init then exit; // no rows get out
  Randomize;
  repeat
    tg_setField( 'Rename', '[' + PadLeft( IntToStr(Random(100)), 3, '0' ) + '] ' + tg_getfield('Rename') );
  until not tg_Skip;
end.