Created
April 1, 2020 17:20
-
-
Save wbhinton/8aed9879282dc44b888b053beb778fe1 to your computer and use it in GitHub Desktop.
Move all files from subfolders in a parent directory up to the parent directory. It essentially flattens a folder structure, dumping all files into the parent folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
target = input("What is the starting directory?") | |
def files2parent(target): | |
for root, dirs, files in os.walk(target): | |
for file in files: | |
try: | |
path_file = os.path.join(root,file) | |
shutil.move(path_file,target) | |
except: pass | |
files2parent(target) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment