Advertisement
Guest User

Untitled

a guest
May 11th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import os, os.path, shutil
  4.  
  5. def sortcopy(src, dst):
  6.     for entry in sorted(os.listdir(src), key=lambda x: x.lower()):
  7.         fullsrc = os.path.join(src, entry)
  8.         fulldst = os.path.join(dst, entry)
  9.         if os.path.isdir(fullsrc):
  10.             if not os.path.exists(fulldst):
  11.                 os.mkdir(fulldst)
  12.             sortcopy(fullsrc, fulldst)
  13.         else:
  14.             print fulldst
  15.             shutil.copyfile(fullsrc, fulldst)
  16.  
  17. sortcopy('/home/hstubbe/Music/', '/media/USBSTICK/')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement