Skip to content

Instantly share code, notes, and snippets.

@DeflatedPickle
Created August 2, 2022 18:18
Show Gist options
  • Save DeflatedPickle/e4bf34afd8e5c9ee5021d3913fbbba58 to your computer and use it in GitHub Desktop.
Save DeflatedPickle/e4bf34afd8e5c9ee5021d3913fbbba58 to your computer and use it in GitHub Desktop.
# moves all files from all directories in the current working directory to a folder
import os
import shutil
old_path = os.getcwd()
new_path = f"{old_path}/ext"
if not os.path.exists(new_path):
os.mkdir(new_path)
for i in os.listdir(old_path):
print(f"dir \"{i}\"")
if os.path.isdir(i):
for f in os.listdir(f"{old_path}/{i}"):
print(f"file \"{f}\"")
shutil.move(
f"{old_path}/{i}/{f}",
f"{new_path}/{f}"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment