title: read multiple files with same name but different extension Python
body: <p>i trying to read and write files from folder with same names, BUT different extensions => extract data from them => rewrite. Here is my code:</p>
  
  <pre><code>for header_name in glob.glob(os.path.join(folder_path, "*.json")):
      for nii_name in glob.glob(os.path.join(folder_path, "*.nii")):
          with open(header_name, "r") as f:
          nii_meta = json.load(f)
          add_stc = slicetime(header_name).tolist()
          nii_meta["SliceTiming"] = add_stc
      with open(header_name, 'w') as f:
          json.dump(nii_meta, f, indent=2)
  </code></pre>
  
  <p>i tried to do check:</p>
  
  <pre><code>    h_name = os.path.splitext(os.path.basename(header_name))[0]
      n_name = os.path.splitext(os.path.basename(nii_name))[0]
      if h_name == n_name:
          do smth with data form files
  </code></pre>
  
  <p>but without succes
  Names of files are sub01_T1w.json, sub01_T1w.nii.gz, sub01_T1w1.json, sub01_T1w1.nii.gz ...</p>