title: Move the file from one directory to multiple sub-folders
body: <p>I want to move the video files from 1 folder to individual sub-folders</p>
  
  <p>I made the script for making video from frames. It creates multiple videos properly but only at 1 particular path. Below is the code</p>
  
  <pre><code>def frames_to_video(detected_object_input,video_op,fps):
  
      folders=glob(detected_object_input)
      img_list=[]
      frame_array=[]
  
      for folder in folders:
          folder_name=os.path.basename(folder)
          vid_ext=".mp4"
          vid_name = folder_name+vid_ext
          final_op=video_op+"\\"+vid_name
          #print(final_op)
  
          for f in glob(folder+"/*jpg"):
              img_list.append(f)
  
          for i in range(len(img_list)):
              filename = img_list[i]
              img=cv2.imread(img_list[i])
              height,width,layers=img.shape
              size=(width,height)
              print(filename)
              frame_array.append(img)
  
              out = cv2.VideoWriter(final_op,cv2.VideoWriter_fourcc(*'DIVX'),fps,size)
  
              for i in range(len(frame_array)):
                  out.write(frame_array[i])
              out.release()
  
  
  detected_object_input= ("C:\\new_multi_cat\\models\\research\\object_detection\\my_imgs\\*")
  video_op= ("C:\\new_multi_cat\\models\\research\\object_detection\\my_imgs")
  fps= 2
  frames_to_video(detected_object_input, video_op, fps)
  </code></pre>
  
  <p>Suppose there is folder X. It has multiple sub-folders like A,B,C. My code makes video files as per the names of the folder i.e videoA, videoB, videoC,etc. But these videos are created in folder X. I want these video files to be created in their respective sub-folders like videoA inside sub-folder A, videoB inside sub-folder B,etc</p>