Skip to content

Instantly share code, notes, and snippets.

@mubbashir10
Created March 12, 2016 14:17
Show Gist options
  • Save mubbashir10/54fe258bc5e330f41e17 to your computer and use it in GitHub Desktop.
Save mubbashir10/54fe258bc5e330f41e17 to your computer and use it in GitHub Desktop.
A simple script (written in python) that I used to move thousands of .mp3 files from different nested folders to music folder.
#importing libraries
import os
import shutil
#define source dir
src_dir = "temp/"
#define destination dir
des_dir = "temp2"
#defines extension
ext = '.mp3'
#file walker
for root, dirs, files in os.walk(src_dir):
for file in files:
#to move files with above mentioned extension (remove this to move all files)
if file.endswith(ext):
#printing current file and it's name
print root+"/"+file
#moving current file
shutil.move(root+"/"+file, des_dir+"/"+file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment