Created
          August 1, 2013 17:09 
        
      - 
      
 - 
        
Save navyjeff/6133313 to your computer and use it in GitHub Desktop.  
    I used this to move all my video files from one directory into their own subdirectories with the same name as the file.
  
        
  
    
      This file contains hidden or 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 | |
| import fnmatch | |
| path = os.getcwd() | |
| filelist = os.listdir(path) | |
| files = fnmatch.filter(filelist, '*.avi') | |
| # If you have more than one file type: | |
| # files += fnmatch.filter(filelist, '*.m4v') | |
| # files += fnmatch.filter(filelist, '*.mkv') | |
| for name in filelist: | |
| os.mkdir(name[:-4]) | |
| shutil.move(name,name[:-4]) | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment