title: My batch file doesn't create the excel file wanted
body: <p>I created a batch file to run my python file in the task scheduler, but when I run my .bat file, it skips a loop that creates a excel file
  this is the python code:</p>
  <pre><code>import os
  import time
  import shutil
  import pathlib
  import pandas as pd
  
  current_path = pathlib.Path().cwd()
  file_name = &quot;Desktop\dossier_test&quot;
  root = os.path.join(pathlib.Path().cwd(),file_name)
  
  
  def remove_files_by_modification_time(r):
      for i in os.listdir(r):
          path=os.path.join(r,i)
          if os.stat(path).st_mtime &lt;=months:
              if os.path.isfile(path):
                  os.remove(path)
              else:
                  print (&quot;impossible de supprimer&quot;)
  
  
  results=[]
  def show_folders_by_size(r):
      size_by_Mb = 0
      for ele in os.scandir(r):
          size_by_Mb+=os.path.getsize(ele)
      size_by_Mb=size_by_Mb//1048576
      path=r
      results.append(dict(path=path, size_by_Mb=size_by_Mb))
  
  
  months = time.time()-(3*2628000)
  for root, dirs, files in os.walk(root):
      for dir in dirs:
          if (&quot;back&quot; in dir):
              path_back=os.path.join(root,dir)
              remove_files_by_modification_time(path_back)    
          elif (&quot;dev&quot; in dir):
              path_dev=os.path.join(root,dir)
              show_folders_by_size(path_dev)
              resultsDf=pd.DataFrame(results)
              resultsDf= resultsDf.sort_values(by=['size_by_Mb'], ascending=False)
              resultsDf.to_excel('C:\\Users\\mbarrech\\Desktop\\folders_by_size.xlsx', sheet_name='products by size in Mb', index=False)
  </code></pre>
  <p>this is the batch file i created:</p>
  <pre><code>C:\Users\mbarrech\Anaconda3\envs\testpy\python.exe C:\Users\mbarrech\filescleaning.py
  pause
  </code></pre>