Rename based on Other file

A swapping-ground for Regular Expression syntax

Rename based on Other file

Postby gonzalu » Fri Mar 05, 2010 7:57 am

Hello,

I have a need to rename files that are named the same but with different extensions. Basically here is the problem. I have a Movie Jukebox library and each film has a few files associated with it. For example:

Star Trek [2009] BLU-RAY.mkv

That is the main title. However, for my jukebox software, there are also companion files for the meta data, the poster and fanart. Unfortunately, the program used to generate these screwed up and named all the companion files all lowercase:

star trek [2009] blu-ray.jpg
star trek [2009] blu-ray.nfo
star trek [2009] blu-ray.fanart.jpg

So I'd like to be able to rename the companion files to MATCH the case of the master file. So sort of a compare rename function... Simply using Sentence case will not work because certain movie names don't necessarily have a matching set of casing such as sentence or upper or lower. There is a lot of case mixing.

Original file name data is gathered from IMDb.com

Thank you so much for your help!

Cheers
Manny
gonzalu
 
Posts: 3
Joined: Fri Mar 05, 2010 7:52 am

Re: Rename based on Other file

Postby Stefan » Fri Mar 05, 2010 3:37 pm

gonzalu wrote:Hello,

I have a need to rename files that are named the same but with different extensions. Basically here is the problem. I have a Movie Jukebox library and each film has a few files associated with it. For example:

Star Trek [2009] BLU-RAY.mkv

That is the main title. However, for my jukebox software, there are also companion files for the meta data, the poster and fanart. Unfortunately, the program used to generate these screwed up and named all the companion files all lowercase:

star trek [2009] blu-ray.jpg
star trek [2009] blu-ray.nfo
star trek [2009] blu-ray.fanart.jpg

So I'd like to be able to rename the companion files to MATCH the case of the master file. So sort of a compare rename function... Simply using Sentence case will not work because certain movie names don't necessarily have a matching set of casing such as sentence or upper or lower. There is a lot of case mixing.

Original file name data is gathered from IMDb.com

Thank you so much for your help!

Cheers
Manny


Hallo Manny,

this is not possible with such an renamer, you have to use an script like JScript, VBScript, PowerShell or AutoHotkey.

Pseudo code:
Code: Select all
Step 1:
- collect all Files With mkv extension into an array arrayMKVs

Step 2:
For Each mkv_File In arrayMKVs
   mkv_BaseName = base name of mkv_File without mkv extension //e.g.  "Star Trek [2009] BLU-RAY" without ".mkv"

   For Each FILE In FOLDER
   file_ext = extension of FILE
   file_base = base name of FILE

        IF (file_base = mkv_BaseName) && (file_ext Not "mkv") Then
         rename FILE to temp + FILE_ext
         rename temp to mkv_BaseName + FILE_ext
         delete temp + FILE_ext
   End If

   Next

Next
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Rename based on Other file

Postby gonzalu » Fri Mar 05, 2010 4:39 pm

OH My god! you're so kind thank you sir :mrgreen:

Is that a VB script? I will play around with it and see if I can get it to work. I am a total dweeb with code :-(

Thanks and CHEERS!!

Manny
gonzalu
 
Posts: 3
Joined: Fri Mar 05, 2010 7:52 am

Re: Rename based on Other file

Postby Stefan » Fri Mar 05, 2010 9:50 pm

gonzalu wrote:Is that a VB script?

No it's not, it's an pseudo code only. It's like an howto to code this.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Rename based on Other file

Postby gonzalu » Sat Mar 06, 2010 12:13 am

Ah, gotcha, I told you I was a dweeb... thanks much.
gonzalu
 
Posts: 3
Joined: Fri Mar 05, 2010 7:52 am


Return to Regular Expressions