title: Python shutil file move in os walk for loop
body: <p>The code below searches within a directory for any PDFs and for each one it finds it moves into the corresponding folder which has '_folder' appended.
  Could it be expressed in simpler terms? It's practically unreadable. Also if it can't find the folder, it destroys the PDF!</p>
  
  <pre><code>import os
  import shutil
  
      for root, dirs, files in os.walk(folder_path_variable):
          for file1 in files:
              if file1.endswith('.pdf') and not file1.startswith('.'):
                  filenamepath = os.path.join(root, file1)
                  name_of_file = file1.split('-')[0]
                  folderDest = filenamepath.split('/')[:9]
                  folderDest = '/'.join(folderDest)
                  folderDest = folderDest + '/' + name_of_file + '_folder'
                  shutil.move(filenamepath2, folderDest)
  </code></pre>
  
  <p>Really I want to traverse the same directory after constructing the variable name_of_file and if that variable is in a folder name, it performs the move. However I came across issues trying to nest another for loop...</p>