Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import os
  2. import sys
  3. from shutil import copy
  4.  
  5. def main():
  6. if len(sys.argv) > 1:
  7. if not os.path.exists('CppPresentations'): # checks whethear the directory exists and creates it if required
  8. os.makedirs('CppPresentations')
  9.  
  10. path = sys.argv[1]
  11. dirs = [path + '/' + dir for dir in os.listdir(path) if os.path.isdir(path + '/' + dir)] # finds all the sub directories of the given path
  12. presentations = [dir + '/' + file for dir in dirs for file in os.listdir(dir) if file.endswith('.pptx')] # gets all the presentations pathes
  13. for file in presentations:
  14. copy(file, 'CppPresentations') # copies it
  15. else:
  16. print 'usage: <path>'
  17.  
  18. if __name__ == "__main__":
  19. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement