unit renametoid3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,id3, StdCtrls;

type
  TForm1 = class(TForm)
    prog: TLabel;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

var
nm : tid3tag;

{$R *.dfm}

function stripnasties(s : string) : string;
var
  n: Integer;
  ss : string;
  good : boolean;
begin
result:='';
  for n := 1 to length(s)  do begin
   good:=true;
   if (s[n]='/') then good:=false;
   if (s[n]='\') then good:=false;
   if (s[n]=':') then good:=false;
   if (s[n]='*') then good:=false;
   if (s[n]='?') then good:=false;
   if (s[n]='"') then good:=false;
   if (s[n]='<') then good:=false;
   if (s[n]='>') then good:=false;
   if (s[n]='|') then good:=false;
   if good=true then result:=result+s[n];


  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
dest,src : array[0..255] of char;
ss : string;
begin
try
nm:=readtag(paramstr(1));
ss:=stripnasties(nm.track+'-'+nm.artist+'-'+nm.album+'.mp3');
ss:=copy(ss,1,254);
ss:='c:\music for phone\'+ss;
strpcopy(dest,ss);
strpcopy(src,paramstr(1));
copyfile(src,dest,false);
prog.Caption:=dest;
except
end;
application.terminate;

end;

end.