title: Modify code to create file in newly created folder
body: <p>From <a href="https://raspberrypi.stackexchange.com/questions/26714/can-i-record-a-24-hour-video-on-the-raspberry-pi-with-camera-module">https://raspberrypi.stackexchange.com/questions/26714/can-i-record-a-24-hour-video-on-the-raspberry-pi-with-camera-module</a> I'm attempting to modify code : </p>
  
  <pre><code>import io
  import itertools
  import picamera
  
  def outputs():
      for i in itertools.count(1):
          yield io.open('file%02d.h264' % i, 'wb')
  
  with picamera.PiCamera() as camera:
      camera.resolution = (640, 360)
      camera.framerate = 24
      for output in camera.record_sequence(
              outputs(), quality=20, bitrate=750000):
          while output.tell() &lt; 1048576:
              camera.wait_recording(0.1)
          if output.name == 'file99.h264':
              break
  </code></pre>
  
  <p>This code will "produce 100 files rolling over once each reaches >1Mb,"</p>
  
  <p>I'm attempting to modify so that once file reaches > 5Mb a new file is created. Directories ranging from 1 to 100 should be created with each containing a max of 100 files. Here is my progress so far : </p>
  
  <pre><code>import io
  import itertools
  import picamera
  import os
  
  def outputs():
      for i in itertools.count(1):
          yield io.open('file%02d.h264' % i, 'wb')
  
  for i in range(1 , 101) :
  
      os.mkdir(str(i))
      with picamera.PiCamera() as camera:
          camera.resolution = (640,480)
          camera.framerate = 24
          for output in camera.record_sequence(
                  outputs(), quality=20, bitrate=750000):
              while output.tell() &lt; 5048576:
                  camera.wait_recording(0.1)
              if output.name == 'file99.h264':
  </code></pre>
  
  <p>How to create the file in the newly created folder and check this newly created folder that it contains 100 files ?</p>