title: Lost files while tried to move files using python shutil.move
body: <p>I had 120 files in my source folder which I need to move to a new directory (destination). The destination is <code>made</code> in the function I wrote, based on the <code>string</code> in the filename. For example, here is the function I used.</p>
  
  <pre><code>path   ='/path/to/source'
  dropbox='/path/to/dropbox'
  files = = [os.path.join(path,i).split('/')[-1] for i in os.listdir(path) if i.startswith("SSE")]
  sam_lis      =list()
  for sam in files:
      sam_list =sam.split('_')[5]
      sam_lis.append(sam_list)
      sam_lis  =pd.unique(sam_lis).tolist()
  
  # Using the above list
  ID  = sam_lis
  
  def filemover(ID,files,dropbox):
      """
      Function to move files from the common place to the destination folder
      """
      for samples in ID:
          for fs in files:
              if samples in fs:
                  desination = dropbox  + "/"+ samples + "/raw/"
                  if not os.path.isdir(desination):
                      os.makedirs(desination)
          for rawfiles in fnmatch.filter(files, pat="*"):
              if samples in rawfiles:
                  shutil.move(os.path.join(path,rawfiles), 
                              os.path.join(desination,rawfiles))
  </code></pre>
  
  <p>In the function, I am creating the destination folders, based on the ID's derived from the files list. When I tried to run this for the first time it threw me <code>FILE NOT exists error</code>. 
  However, later when I checked the source all files starting with <code>SSE</code> were missing. In the beginning, the files were there. I want some insights here;</p>
  
  <ol>
  <li>Whether or not <code>os.shutil.move</code> moves the files to somewhere like a temp folder instead of destination folder?</li>
  <li>whether or not the <code>os.shutil.move</code> deletes the files from the source in any circumstance?</li>
  <li>Is there any way I can test my script to find the potential reasons for missing files?</li>
  </ol>
  
  <p>Any help or suggestions are much appreciated?</p>