Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os,re,time
- folder1 = '/root/python/picA'
- folder2 = '/root/python/picB'
- Dicta = {}
- Dictb = {}
- for path, subdirs, files in os.walk(folder1):
- for name in files:
- Dicta[time.ctime(os.path.getmtime(os.path.join(path, name)))] = os.path.join(path, name)
- for path, subdirs, files in os.walk(folder2):
- for name in files:
- Dictb[time.ctime(os.path.getmtime(os.path.join(path, name)))] = os.path.join(path, name)
- for name in Dicta:
- if name in Dictb:
- #print Dicta[name]+' => '+os.path.dirname(Dicta[name])+'/'+os.path.split(Dictb[name])[1]
- os.rename(Dicta[name],os.path.dirname(Dicta[name])+'/'+os.path.split(Dictb[name])[1])
- print "Complete"
- # Ref.
- #http://www.tutorialspoint.com/python/python_dictionary.htm
- #http://docs.python.org/release/2.5.2/lib/typesmapping.html
- #http://stackoverflow.com/questions/2909975/python-list-directory-subdirectory-and-files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement