Rename Files

Comments on existing version & Suggestions for future versions. If you want a new feature suggest it here. Discussions about beta versions also come in this section.
Post Reply
Penanders
Posts: 17
Joined: 2006-09-26 11:50:55
Location: Italia (Italy)

Rename Files

Post by Penanders »

Do You think it's possible to rename the movie File with the value of the field transalated (or orignal) title by the scripts method?

It would be useful and really easy for the ant renamer programmer..
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Using scripts it is possible actually.
As long as the title does not contain forbidden characters.

If you do something like that:

Code: Select all

program NewScript;
begin
  Launch('cmd /c ren "' + GetField(fieldUrl) + '" "' + GetField(fieldTranslatedTitle) + '.avi"');
end.
(not tested)
But this will open one console window per movie (it will be closed once renamed), so if you plan to do it on many movies it is maybe better to write the "ren" commands in a text field (using a TStringList) with a ".bat" extension, that you can launch manually later.
Penanders
Posts: 17
Joined: 2006-09-26 11:50:55
Location: Italia (Italy)

Post by Penanders »

Uhmm

"launch" procedure seems to have problems with "cmd" command..
It work not at all.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Sorry, I forgot that parameter was separated:

Code: Select all

program NewScript;
begin
  Launch('cmd', '/c ren "' + GetField(fieldUrl) + '" "' + GetField(fieldTranslatedTitle) + '.avi"');
end.
Penanders
Posts: 17
Joined: 2006-09-26 11:50:55
Location: Italia (Italy)

Post by Penanders »

Yes. It's as you suggest.

I've already solved so:

Code:
program Rename;
Var
Temp, Perc :String;
BegPos : integer;
begin
Launch('CMD','/C rename "'+GetField(FieldUrl)+'" "'+GetField(FieldTranslatedTitle)+'.avi"') ;
Perc := GetField(FieldUrl); // rinomina l'URL
Temp := '';
Repeat
BegPos := Pos('\', Perc);
Temp := Temp + (Copy(Perc,1,BegPos));
Delete(Perc,1,BegPos)
Until Begpos = 0;
Temp := Temp + (Getfield(FieldTranslatedTitle))+'.avi';
SetField(FieldUrl,temp);
end.


I would like a more practical script (i.e.: a bat file for several movies as you suggest) for the forbidden characters too.

I'm tryng to write it (It's easy i suppose).

Thanks for your help.

Ciao
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

For the batch file you can see how the "find duplicate" script reads/writes a TStringList.

To prevent forbidden characters, a for-loop on the string to check each character and replace it if needed should do the trick.
Something like that:

Code: Select all

for i := 1 to Length(s) do
begin
  if c := StrGet(s, i);
  if (c <> '?') and (c <> '*') etc... then
    s2 := s2 + c;
end;
Post Reply