Skip to content

Instantly share code, notes, and snippets.

@JakubKoralewski
Created April 18, 2019 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakubKoralewski/2a798cf52516af021fde62673bd524a2 to your computer and use it in GitHub Desktop.
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
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