Skip to content

Instantly share code, notes, and snippets.

@isaacgr
Created June 2, 2019 03:32
Show Gist options
  • Save isaacgr/5f2c5a76e81b8ee0fc9a43b9b9ccb329 to your computer and use it in GitHub Desktop.
Save isaacgr/5f2c5a76e81b8ee0fc9a43b9b9ccb329 to your computer and use it in GitHub Desktop.
Script to move files out of a folder and into root directory
import shutil
import os
def main():
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
if name.endswith('.bmp'):
thefile = os.path.join(root, name)
current_dir = os.getcwd()
shutil.move(thefile, current_dir)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment