Page 1 of 1

[REL] Rename file Names

Posted: 2014-03-17 22:10:27
by fulvio53s03
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 file Path Field) following these optional criterias:
- Translated Title or original Title or Formatted Title
- Director (Between Brackets)
- Year
- 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 that you can open with block notes, control it, rename in c:\rename.bat and then execute it.
Obviousely...... be careful!!!
:hihi:

Code: Select all


C h a n g e d 

;)

Re: [REL] [ITA] Rename file Names

Posted: 2014-03-18 09:49:24
by antp
fulvio53s03 wrote:open with block notes
"notepad" ;)

Re: [REL] [ITA] Rename file Names

Posted: 2014-03-18 15:29:24
by fulvio53s03
antp wrote:
fulvio53s03 wrote:open with block notes
"notepad" ;)
:ha: uh oh.. :hihi:
as my teacher said to me: "never trust in your studies! Use google translator!"
:badidea:

Anyway, would you insert it in your next releases? i think it could be useful and it is easily Customizable for everyone's need.

:innocent:

Posted: 2014-03-18 20:10:58
by antp
Yes I'll include it.
But I just wonder why you posted it as an "ITA" script, as it is rather language-neutral.
Also, explanation on how to use it could be put in the comments of the script, so they would be visible when it is selected ;)

Posted: 2014-03-18 23:05:36
by fulvio53s03
Well, I got your suggestions (and i found a mistake too). Only a little problem. I would like to add a 'pause' (dos command) as my script's last line (so, after using .bat file produced, one can see if there were messages about execution's errors).
How can I do?
Would you like to modify my script this way?

Code: Select all

B e i ng   C h a n g e d 

thanks. :stupid:

Posted: 2014-03-19 10:15:30
by antp
You forgot to change the input box title "Find Duplicates" :D
After using the .bat script, the file names stored in the catalog won't match the actual names. So I wonder if there is so much use of such script in the end?
I remember having previously posted on the forum a script doing the change itself, so updating the catalog at the same time to keep the right paths stored.

I think there is a way to know when you reach the end of the movie list (it would also allow to save only once, at the end), but that's part of the functions added in versions 4.x by soulsnake - these should be in the help file ;)

Posted: 2014-03-19 17:36:25
by fulvio53s03
antp wrote:... I think there is a way to know when you reach the end of the movie list (it would also allow to save only once, at the end), but that's part of the functions added in versions 4.x by soulsnake - these should be in the help file ;)
Sorry, I cannot find that function ... :cry:
help! :??:

Posted: 2014-03-19 18:28:05
by soulsnake
Hi,

If you want, I already made a script named RenameFiles.ifs to rename files and update the field contening filename with the new name.

To know if you are at the beginning or at the end of the movie list you can do this :

Code: Select all

if GetIteration = 0 then
begin
  // begin of the list (first movie)
end
else if GetIteration = GetIterationCount-1 then
begin
  // end of the list (last movie)
end
else
begin
  // other movies
end;
Soulsnake.

Posted: 2014-03-21 04:54:49
by fulvio53s03

Code: Select all


script changed


Posted: 2014-03-21 10:04:13
by antp
But then what's the purpose of making a batch file rather than renaming files directly via the script?

Posted: 2014-03-21 11:53:04
by fulvio53s03
antp wrote:But then what's the purpose of making a batch file rather than renaming files directly via the script?
Bah... I prefer to see the old/new file name before making changes. :hum:
Anyway, I don't find your script. What is its name? or is it only in a post in the forum???
Maybe I could like it more than mine.... ;)

Posted: 2014-03-21 12:33:48
by antp
viewtopic.php?p=29119#29119
but that should improved to handle forbidden characters

Posted: 2014-03-23 14:42:57
by fulvio53s03
antp wrote:viewtopic.php?p=29119#29119
but that should improved to handle forbidden characters
Well, I took a look to the topic (thanks) but i'm sorry to say that my script (even not perfect) looks to be a little more complete.
Any suggestion is well accepted.
:)

Posted: 2014-04-20 07:06:07
by fulvio53s03
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.
:)

Re:

Posted: 2020-05-27 12:04:30
by al0203
antp wrote: 2014-03-19 10:15:30 You forgot to change the input box title "Find Duplicates" :D
After using the .bat script, the file names stored in the catalog won't match the actual names. So I wonder if there is so much use of such script in the end?
I remember having previously posted on the forum a script doing the change itself, so updating the catalog at the same time to keep the right paths stored.

I think there is a way to know when you reach the end of the movie list (it would also allow to save only once, at the end), but that's part of the functions added in versions 4.x by soulsnake - these should be in the help file ;)
Can you tell me which is the function to rename files directly? I tried RenameFiles, but it doesn´t exist. Also you commet you posted another script to rename file, can you tell me the name? I´m not able to find it. Thank you.

Re: [REL] Rename file Names

Posted: 2020-05-28 06:05:43
by antp
Back then, I posted the link a little further in the discussion
It seems it was that thread then: viewtopic.php?p=29119#29119

Re: Re:

Posted: 2020-05-28 10:20:17
by fulvio53s03
al0203 wrote: 2020-05-27 12:04:30 Can you tell me which is the function to rename files directly? I tried RenameFiles, but it doesn´t exist. Also you commet you posted another script to rename file, can you tell me the name? I´m not able to find it. Thank you.
The correct script name is "rinomina films" but maybe my script was never inserted as an "official" script.
If you want to use it, maybe necessary to take it from this thread, few posts over this, or write me in m.p. and I'll send it to you.
:innocent: