A little update: now i get new filename extension from the old filename.
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Fulvio53s03
Title=rename films
Description=rename films
Site=
Language=?
Version=1.2
Requires=4.1
Comments=After importing informations from movies contained in a folder and after importing informations about movies from internet...... this Script will Rename your movies' file names (contained in field File Path) using these optional criterias: 1) Translated Title or original Title or Formatted Title 2) Director (Between Brackets) 3) Year 4) Languages i.e. from "Y:\Film\Film da catalogare\The Machinist (2004) 1080p.mkv" you can obtain ""L'uomo Senza Sonno (The Machinist) (Brad Anderson) 2004 ENG, ITA, ENG.mkv". Using it, you will obtain a file named c:\rename.bat.txt (or any other name you choose) that you can open with notepad, control it, rename in c:\rename.bat and then execute it. The script can updates field File Path in Catalog or leave it unchanged (default), Obviousely...... be careful!!!
License=GPL
GetInfo=0
RequiresMovies=1
[Options]
Title=1|1|0=Formatted Title|1=Translated Title|2=Original Title
Director=1|1|1=Yes|0=No
Year=1|1|1=Yes|0=No
Languages=1|1|1=Yes|0=No
Update_path=0|0|1=Yes|0=No
[Parameters]
***************************************************)
program RenameFilm;
uses
StringUtils1;
var
MovList: TStringList;
DupList: TStringList;
NewName: string;
ResultPath: string;
Titlenew, Linguaggi, CampoAnno, OldPath, NewPath: string;
Titolo, Regista, Anno, Lingue, PosBar, Aggiorna_path: integer;
Giri, giri_fatti, lgth_path: integer;
Procedure ChangeLanguages;
begin
Linguaggi := AnsiUpperCase(Linguaggi);
Linguaggi := StringReplace(Linguaggi, 'ENGLISH', 'ENG');
Linguaggi := StringReplace(Linguaggi, 'SPANISH', 'ESP');
Linguaggi := StringReplace(Linguaggi, 'FRENCH', 'FRA');
Linguaggi := StringReplace(Linguaggi, 'ITALIAN', 'ITA');
Linguaggi := StringReplace(Linguaggi, ', ', '_');
Linguaggi := fulltrim(Linguaggi);
end;
procedure Elaborazione;
begin
NewName := '"';
if Titolo = 1
then NewName := Newname + Getfield(fieldTranslatedTitle);
if Titolo = 2
then NewName := Newname + Getfield(fieldOriginalTitle);
if Titolo = 0
then NewName := Newname + Getfield(fieldFormattedTitle);
if regista = 1
then NewName := NewName + ' (' + Getfield(fieldDirector) + ')';
CampoAnno := Getfield(FieldYear);
if Anno = 1
then NewName := NewName + ' ' + CampoAnno;
Linguaggi := Fulltrim(Getfield(FieldLanguages));
ChangeLanguages;
if length(Linguaggi) > 0
then Linguaggi := ' ' + Linguaggi;
if Lingue = 1
then NewName := NewName + Linguaggi;
OldPath := getField(FieldFilePath);
lgth_path := length(Oldpath);
PosBar := AnsiLastPosEx('.', OldPath, true, true);
delete(OldPath, (1), (PosBar-1)); //cut old filename
NewName := Newname + Oldpath;
OldPath := getField(FieldFilePath);
lgth_path := length(Oldpath);
If Aggiorna_path = 0
then lgth_path := 0;
If lgth_path > 0 then
begin
PosBar := AnsiLastPosEx('\', OldPath, true, true);
if PosBar > 0 then
begin
delete(OldPath, (posbar + 1), (lgth_path - PosBar)); //cut old filename
Newpath := Oldpath + stringReplace(NewName, '"', '');
SetField(FieldFilePath, Newpath);
end
end
if length(getField(FieldFilePath)) > 0 then
begin
Titlenew := 'ren "' + OldPath + '" ' + NewName + '"';
DupList.Add(Titlenew); //scrivi riga
end
end;
//
//MAIN PROGRAM
//
begin
if StringUtils1_Version < 3 then
begin
ShowMessage('File "stringutils1.pas" is too old, please download a new version of it');
Error;
end;
if ResultPath = '' then
begin
ResultPath := 'c:\rename.bat.txt';
Input('Update/Aggiorna Films', 'Store results to: / Salva Risultati in: ', ResultPath);
Titolo := GetOption('Title');
Regista := GetOption('Director');
Anno := GetOption('Year');
Lingue := GetOption('languages');
Aggiorna_path := GetOption('Update_path');
if Aggiorna_path = 1 then
begin
ShowMessage('Attenzione! State per modificare il campo "file path" dei film nel Catalogo! Advertence! You are going tu update field "file path" in Catalog!');
end
if Aggiorna_path = 0 then
begin
ShowMessage('Attenzione! Il campo "file path" dei film nel Catalogo non verrà aggiornato! Advertence! Field "file path" in Catalog will not be updated!');
end
giri := GetiterationCount;
if MovList = nil then
MovList := TStringList.Create;
if DupList = nil then
begin
DupList := TStringList.Create;
end
end;
Elaborazione;
giri_fatti := GetIteration;
if giri_fatti = Giri-1 then //fine elaborazione
begin
Titlenew := 'pause';
DupList.Add(Titlenew); //scrivi riga
DupList.SaveToFile(ResultPath); //chiudi file
end
end.