Created
April 18, 2019 10:37
-
-
Save JakubKoralewski/2a798cf52516af021fde62673bd524a2 to your computer and use it in GitHub Desktop.
python move first level child files from directories to root of script, not recursive
This file contains 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 | |
root = os.path.split(__file__)[0] | |
for dirpath, dirname, filenames in os.walk(root): | |
if filenames: | |
for file in filenames: | |
old_path = os.path.join(dirpath, file) | |
new_path = os.path.join(root, file) | |
shutil.move(old_path, new_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment