Skip to content

Instantly share code, notes, and snippets.

@shibukawa
Created May 11, 2013 07:09
Show Gist options
  • Save shibukawa/5559165 to your computer and use it in GitHub Desktop.
Save shibukawa/5559165 to your computer and use it in GitHub Desktop.
Copy pictures and merged into Picasa folder from Dropbox camera upload folder
import os, time, shutil
distroot = r"c:\Users\shibu\newPictures"
created_dirs = set()
for dirpath, dirnames, filenames in os.walk(r"C:\Users\shibu\Dropbox\Camera Uploads"):
print(dirpath)
for filename in filenames:
fullpath = os.path.join(dirpath, filename)
dirname = filename[0:10]
if os.path.splitext(filename)[1] != '.jpg':
continue
print(filename + ' -> ' + dirname)
distdir = os.path.join(distroot, dirname)
if distdir not in created_dirs and not os.path.exists(distdir):
os.makedirs(distdir)
created_dirs.add(distdir)
print(" %s created" % dirname)
distpath = os.path.join(distdir, filename)
shutil.copy2(fullpath, distpath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment