Advertisement
clockworkpc

Scan for empty folders and delete them

Jun 11th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. #!/usr/bin/python
  2. #/home/clockworkpc/bin/empty_folder.py
  3.  
  4. # Released under a GPLv3 Licence by Clockwork PC 2013
  5. # www.clockworkpc.com.au
  6.  
  7. # You are entitled to the following four freedoms:
  8. # Freedom 0: To run this program for any purpose
  9. # Freedom 1: To study how this program works and change it to make it do what you wish
  10. # Freedom 2: To redistribute copies so you can help your neighbour
  11. # Freedom 3: To distribute copies of your modified version to others
  12.  
  13. import os
  14.  
  15. # Change to the folder you wish to scan
  16. work_path = os.getenv("HOME") + "/Videos/tubemixing/NamedVideos/"
  17.  
  18. for file in os.listdir(work_path):
  19.     if not os.listdir(work_path+file):
  20.         print "empty"
  21.         os.rmdir(work_path+file)
  22.     else:
  23.         print "not empty"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement