Folder Flattener
This Python code flattens files distributed in multiple folders.
Code
Import required modules
import os
import shutil
Set source path, destination path and collect folder names
destination = "your_destination_path"
source = "your_source_path"
folders = os.listdir(source)
Iterate over the folders
for folder in folders:
file_path = os.path.join(source,folder)
files = os.listdir(file_path)
# Iterate over files in folders
for file in files:
src = os.path.join(file_path,file)
# Move file to destination
dest = shutil.move(src, destination)