title: separate filename after underlining _ os.path
body: <p>In my path <code>/volume1/xx/</code> are several files with this character <code>A_test1.pdf</code>, <code>B_test2.pdf</code>, ...I want to seperate the <code>test1</code> part without path and <code>.pdf</code>.</p>
  
  <p>Im newbie so I tried first with full name
  but I got only the "*.pdf" as a text. 
  What is wrong with the path oder placeholder * ?</p>
  
  <pre><code>splitname = os.path.basename('/volume1/xx/*.pdf')
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>I got 2019-01-18_RG-Telekom[] from orign ReT_march - I want 2019-01-18_RG-Telekom_march (text after underlining)   xx is a folder 
  here is the whole code:</p>
  
  <pre><code>#!/usr/bin/env python3
  import datetime
  import glob
  import os
  import os.path
  
  SOURCE_PATH = '/volume1/xx'
  TARGET_PATH = os.path.join(SOURCE_PATH, 'DMS')
  
  def main():
  
      today = datetime.date.today()
  
      splitnames = [os.path.basename(fpath) for fpath in glob.glob("./xx/*.pdf")]
  
      for prefix, name_part in [
          ('ReA', 'RG-Amazon'),
          ('GsA', 'GS-Amazon'),
          ('ReT', 'RG-Telekom'),
          ('NoE', 'Notiz-EDV'),
      ]:
          filenames = glob.iglob(os.path.join(SOURCE_PATH, prefix + '*.pdf'))
          for old_filename in filenames:
              new_filename = os.path.join(TARGET_PATH, '{}_{}_{}.pdf'.format(today, name_part, splitnames))
              os.rename(old_filename, new_filename)
  
  if __name__ == '__main__':
      main()
  </code></pre>