Advertisement
Guest User

Untitled

a guest
Jul 17th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import os, time, shutil
  2. src_dir=os.getcwd()
  3. print("Working path:", src_dir)
  4. for filename in os.listdir(src_dir):
  5. mtime=time.strftime("Last modification: %b/%Y", time.localtime(os.path.getmtime(filename)))
  6. print("File:",filename,mtime)
  7. mtime_path=time.strftime("\\%Y\\%m", time.localtime(os.path.getmtime(filename)))
  8. dst_dir=os.getcwd()+mtime_path
  9. src_file=os.path.join(src_dir, filename)
  10. dst_file=os.path.join(dst_dir, filename)
  11. if not os.path.exists(dst_dir):
  12. os.makedirs(dst_dir)
  13. shutil.move(src_file, dst_file)
  14. print("Done.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement