jmunsch

python move files

Aug 13th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import os, shutil, traceback
  2.  
  3. pages = 'C:/Users/UserBob/Desktop/RANDOM/pages'
  4. dirs = os.listdir(pages)
  5. print(dirs)
  6.  
  7.  
  8. htmls = 'C:/Users/UserBob/Desktop/RANDOM/nfl_html'
  9.  
  10. for f in os.listdir(htmls):
  11.     try:
  12.         uts = f.split('_')[0]
  13.         source = os.path.join(htmls,f)
  14.         dest = os.path.join(os.path.join(pages, uts),f)
  15.         print(source,dest)
  16.         shutil.move(source,dest)
  17.     except Exception, e:
  18.         print(traceback.format_exc())
  19.         pass
Advertisement
Add Comment
Please, Sign In to add comment