I want to perform a small function to move all files that are ".mp3" to a folder.
For this I have thought to go through all the folders and subfolders in a given direction, and what has occurred to me is the following:
def catch(dir_name):
for item in os.listdir(dir_name):
print(str(item))
if item.endswith(".mp3"):
shutil.move(str(dir_name + "/" + item), "E:/Users/path/destino")
if os.path.isdir(item):
print("subcarpeta" + os.path.join('E:','\Users','path',item))
catch(os.path.join'E:','\Users','path',item))
print("Termino la revision")
Using this, I only do the first pass through the folders, but I do not recursively search the subfolders.