-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimgfoldercleaner.py
More file actions
32 lines (26 loc) · 829 Bytes
/
Copy pathimgfoldercleaner.py
File metadata and controls
32 lines (26 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os, shutil, sys
## README ##
## Instalar Python 3
## sudo python3 -m pip install mysql-connector
## sudo python3 -m pip install Pillow
##
def main():
if len(sys.argv) == 1:
sys.exit("Please pass absolute path of img folder")
srcpath = sys.argv[1]
for root, dirs, files in os.walk(srcpath):
hasImage = False
path = root.split(os.sep)
print (root)
for file in files:
if (file.endswith(".jpg") or file.endswith(".png" or file.endswith(".webp"))):
hasImage = True
if (hasImage):
print ("has image")
else:
print ("no image")
if not hasImage and not dirs:
shutil.rmtree(root)
print ("delete folder:" + root)
if __name__ == "__main__":
main()