title: How can i compare files names in python?
body: <p>I'm getting tired of renaming every episode with its subtitle (i have 100+)</p>
  
  <p>How can I compare the 2 files if they have the same episode number in their name, after that I want it to replace the subtitle to the episode name </p>
  
  <p>I tried to do it my self, I successfully managed to change the name(easy), but the comparison part is what I'm missing.</p>
  
  <p>Thank you.</p>
  
  <p><strong><em>edited:</em></strong></p>
  
  <p>The files names would be like this;</p>
  
  <p>(Episode): [PuyaSubs!] Banana Fish - 12 [1080p].mkv</p>
  
  <p>(Subtitle): Banana Fish - 12.ass</p>
  
  <p>what i came up so far:</p>
  
  <pre><code>import os
  old_file = os.path.join(r"D:\Downloads\Media\Anime\[PuyaSubs!] Banana Fish [1080p][Batch]\Banana Fish - 12.ass", "Banana Fish - 12.ass")
  new_file = os.path.join(r"D:\Downloads\Media\Anime\[PuyaSubs!] Banana Fish [1080p][Batch]\Banana Fish - 12.ass", "[PuyaSubs!] Banana Fish - 12 [1080p][2ECC9207].ass")
  os.rename(old_file, new_file)
  </code></pre>
  
  <p>this will only change the name, but it's not automated and I will have to do it for every subtitle file manually.</p>