Skip to content Skip to sidebar Skip to footer

Python Recursive Find Files And Move To One Destination Directory

The script should recursively go through the rootpath directory and find all files with *.mp4 extension. Print the list of files with the directory structure. Then move the files t

Solution 1:

Congratulations! You have already found os.path.join(). You even use it, on your print call. So you only have to use it with move():

shutil.move(os.path.join(root, filename), os.path.join(destDir, filename))

(But take care not to overwrite anything in destDir.)

Solution 2:

Change the root + filename in the last line to os.path.join(root, filename) (as seen two lines earlier)?

Post a Comment for "Python Recursive Find Files And Move To One Destination Directory"