title: Python - Create directory and move specific file
body: <p>Learning and understanding Python better I want to write a script based on youtube-dl that downloads a playlist and moves all those flv videos in a specific directory. </p>
  
  <p>This is my code so far:</p>
  
  <pre><code>import shutil
  import os
  import sys
  import subprocess
  # Settings
  root_folder = 'C:/Users/Robert/Videos/YouTube/Playlists/$s'
  
  def download():
      files = open('Playlists.txt').readlines()
  
      for playlist in files:
          p = playlist.split(';')
  
      # Create the directory for the playlist if it does not exist yet
      if not os.path.exists (root_folder % p[0]):
          os.makedirs(root_folder % p[0])
  
      # Download every single video from the given playlist
      download_videos = subprocess.Popen([sys.executable, 'youtube-dl.py', ['-cit'], [p[1]]])        
      download_videos.wait()
  
      # Move the video into the playlist folder once it is downloaded
      shutil.move('*.flv', root_folder % p[0])
  
  
  download()
  </code></pre>
  
  <p>The structure of my Playlists.txt looks as follows:</p>
  
  <pre><code>Playlist name with spaces;http://www.youtube.com/playlist?list=PLBECF255AE8287C0F&amp;feature=view_all
  </code></pre>
  
  <p>I run into two problems. First of all the string formatting does not work. </p>
  
  <p>I get the error:</p>
  
  <pre><code>Playlist name with spaces
  Traceback (most recent call last):
    File ".\downloader.py", line 27, in &lt;module&gt;
      download()
    File ".\downloader.py", line 16, in download
      if not os.path.exists (root_folder % p[0]):
  TypeError: not all arguments converted during string formatting
  </code></pre>
  
  <p>Can anybody explain me the reason? When I print p[0] everything looks fine.</p>
  
  <p>Second, I do not have any clue how to set the correct shutil.move command to only move the flv video that was just downloaded. How can I filter that?</p>
  
  <p>Thank you!</p>