I have this Python script that moves all files in a specified directory with a specific file extension. But if the files are located in subdirectories, they won't be moved. How do I move those files too?
import os
import shutil
dest = "/home/thee/Videos/"
sourcePath = raw_input("Enter file location: ")
filetype = raw_input("Enter file type (ex: .mp4): ")
source = os.listdir(sourcePath)
print "Moving all " + filetype + " files from " + sourcePath + " to " + dest
for files in source:
if files.endswith(filetype):
shutil.move(os.path.join(sourcePath,files), os.path.join(dest,files))
print sourcePath + files