#21 2019-03-12 10:05

HexaPro
Member
Registered: 2019-03-03
Posts: 15

Re: Rename file exactly like another file with a different extension

Stefan wrote:

In text form please (for us to create our own test files to test our solution on)

You can just paste it in here.

Ok, wait it's on network drive, can't use cmd to list them.

Offline

#22 2019-03-12 12:37

HexaPro
Member
Registered: 2019-03-03
Posts: 15

Re: Rename file exactly like another file with a different extension

Here it is:

E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\01 - Days Gone Bye.mkv
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\01 - Days Gone Bye.srt
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\02 - Guts.mkv
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\02 - Guts.srt
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\03 - Tell It To The Frogs.mkv
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\03 - Tell It To The Frogs.srt
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\04 - Vatos.mkv
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\04 - Vatos.srt
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\05 - Wildfire.mkv
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\05 - Wildfire.srt
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\06 - TS-19.mkv
E:\Rio\TV Series\The Walking Dead\The Walking Dead Season 1\06 - TS-19.srt
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E01.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E02.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E03.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E04.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E05.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E06.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E07.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E08.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E09.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S01E10.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E01.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E02.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E03.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E04.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E05.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E06.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E07.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E08.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E09.mp4
E:\Rio\TV Series\Game Of Thrones Season 1-5 Complete 720p x264\Game Of Thrones S02E10.mp4

Offline

#23 2019-03-12 13:21

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Rename file exactly like another file with a different extension

Thanks, but
- the "The Walking Dead"  -a: have no MP4 files and -b: the SRT are already done (matching the MKVs).
- the "Game Of Thrones" doesn't show any SRT at all.

So your list doesn't match your request ("rename matching SRTs like corresponding MP4s"). There is nothing I could do for you.


 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#24 2019-03-12 17:03

HexaPro
Member
Registered: 2019-03-03
Posts: 15

Re: Rename file exactly like another file with a different extension

Stefan wrote:

Thanks, but
- the "The Walking Dead"  -a: have no MP4 files and -b: the SRT are already done (matching the MKVs).
- the "Game Of Thrones" doesn't show any SRT at all.

So your list doesn't match your request ("rename matching SRTs like corresponding MP4s"). There is nothing I could do for you.

Seriously? The Walking Dead has been manually renamed by me long time ago.
Here's what I haven't renamed yet:

K:\TV Series\The Last Ship\The Last Ship Season 4\List.txt
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E01 In Medias Res.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E02 The Pillars of Hercules.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E03 Bread & Circuses.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E04 Nostos.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E05 Allegiance.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E06 Tempest.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E07 Feast.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E08 Lazaretto.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E09 Detect, Deceive, Destroy.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The Last Ship S04E10 Endgame.mp4
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E01-In-Medias-Res-SEMUA-HDTV-@basthiantan.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E02-The-Pillars-of-Hercules-SEMUA-HDTV-@basthiantan.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E03-Bread-and-Circuses-SEMUA-HDTV-@basthiantan.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E04-Nostos-SEMUA-HDTV-@basthiant.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E05- Allegiance-SEMUA-HDTV-@basthiant.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E06-Tempest-SEMUA-HDTV-@basthiantan.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E07-Feast-SEMUA-HDTV-@basthiantan.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E08-Lazaretto-SEMUA-HDTV-@basthiantan.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E09-Detect-Deceive-Destroy-SEMUA-HDTV-@basthiantan.srt
K:\TV Series\The Last Ship\The Last Ship Season 4\The-Last-Ship-S04E10-SEASON-FINALE-Endgame-SEMUA-HDTV-@basthiantan.srt

Last edited by HexaPro (2019-03-12 17:31)

Offline

#25 2019-03-12 21:16

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Rename file exactly like another file with a different extension

Stefan wrote:
HexaPro wrote:

.. they usually start with something like S01E01 through S01-E16.

Then they have something common!?


From BEFORE:
The Last Ship S04E01 In Medias Res.mp4
The Last Ship S04E02 The Pillars of Hercules.mp4
The Last Ship S04E03 Bread & Circuses.mp4
The-Last-Ship-S04E01-In-Medias-Res-SEMUA-HDTV-@basthiantan.srt
The-Last-Ship-S04E02-The-Pillars-of-Hercules-SEMUA-HDTV-@basthiantan.srt
The-Last-Ship-S04E03-Bread-and-Circuses-SEMUA-HDTV-@basthiantan.srt

TO:
The Last Ship S04E01 In Medias Res.mp4
The Last Ship S04E01 In Medias Res.srt
The Last Ship S04E02 The Pillars of Hercules.mp4
The Last Ship S04E02 The Pillars of Hercules.srt
The Last Ship S04E03 Bread & Circuses.mp4
The Last Ship S04E03 Bread & Circuses.srt



TRY:

Purpose: Rename *.SRT like *.MP4 with same "S..E.." pattern

- save below code into ReNamer folder as "test.pas" text file, see
http://www.den4b.com/wiki/ReNamer:Rules:PascalScript
- have a backup!!!
- select your main folder and load all files
- add this script as PascalScript-Rule
- click [Preview]
- the base name of all SRT files should be shown as same as like the corresponding MP4 files.


//Stefan 12.03.2019 http://www.den4b.com/forum/viewtopic.php?pid=10774#p10774
//Based on den4b 2007-10-21 http://www.den4b.com/forum/viewtopic.php?pid=1425#p1425
//Purpose: Rename *.SRT like *.MP4 with same "S..E.." pattern:
//  The Last Ship S04E01 In Medias Res.mp4
//  The-Last-Ship-S04E01-In-Medias-Res.srt >> The Last Ship S04E01 In Medias Res.srt


// - - - USAGE
//- save code into ReNamer folder as "test.pas" text file, 
// (see http://www.den4b.com/wiki/ReNamer:Rules:PascalScript)
//- have a backup!!!
//- select your main folder and load all files
//- add this script as PascalScript-Rule
//- click [Preview]
//- the base name of all SRT files should be shown as same as like the corresponding MP4 files.
//

// - - - USER SETTINGS
const
//Extension of files with wanted name:
  strMasterExt= '*.MP4';
//Extension of file to rename like Master:
  strBuddyExt = '.SRT';
//Common pattern from both files to detect pairs:
//Here for "The Last Ship S04E01 In Medias Res.mp4" the "S04E01"-part
  strCommonREpattern = '(.+?)(S\d\dE\d\d)(.+)';
// (See http://www.den4b.com/wiki/ReNamer:Rules:RegEx for an start)

// - - - THE CODE
var
  strArrItem,strCurrDir,strBuddyPattern: WideString;
  arrFilesInFld,arrRegExSubPatterns: TWideStringArray;
  idx:Integer;

begin
      if WideUpperCase(WideExtractFileExt(FileName)) = strBuddyExt then
      begin
        strCurrDir := WideExtractFileDir(FilePath);
        SetLength(arrFilesInFld, 0);
        WideScanDirForFiles(strCurrDir, arrFilesInFld,False, False, False, strMasterExt);
        if Length(arrFilesInFld) <1 then exit;
        arrRegExSubPatterns:=SubMatchesRegEx(FileName,strCommonREpattern,false);
        if Length(arrRegExSubPatterns) <1 then exit;
        strBuddyPattern := arrRegExSubPatterns[1];
        for idx:=0 to Length(arrFilesInFld)-1 do
        begin
          strArrItem := WideExtractFileName(arrFilesInFld[idx]);
          if WidePos(strBuddyPattern,strArrItem) > 0 then
              FileName   := WideExtractBaseName(strArrItem)
                          + WideExtractFileExt(FileName);
        end;
      end;
end.
//

HTH? cool


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#26 2019-03-13 07:03

HexaPro
Member
Registered: 2019-03-03
Posts: 15

Re: Rename file exactly like another file with a different extension

Thank you so much man, it's working. You're my saviour.
So if I want to change the rule a bit, for... let say ".mkv",
then I just need to change every ".mp4" in the script to ".mkv" right?
And if there's other pattern than SxxExx I just need to change the '(.+?)(S\d\dE\d\d)(.+)'; to the corresponding pattern,
like if it's just numbers 01-10, I just need to change it to something like this '(.+?)(d\d)(.+)'; right?
or if it's "Episode-01", I just need to change it to something like this '(.+?)(Episode-d\d)(.+)'; right?

Offline

#27 2019-03-14 13:02

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Rename file exactly like another file with a different extension

Yes, you're basically right here in your assumption, well spotted.
But also see >> http://www.den4b.com/wiki/ReNamer:Regular_Expressions
It must be \d\d for your case ..... not d\d


 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

Board footer

Powered by FluxBB