mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-27 14:01:09 +00:00
Added Clean_up_photo
This commit is contained in:
parent
fa307e01a0
commit
b0e8dbcff0
1
Clean_up_photo_directory/README.md
Normal file
1
Clean_up_photo_directory/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
This program is used to find out the "bad" picture files and then eventually delete them.
|
20
Clean_up_photo_directory/clean_up_photo.py
Normal file
20
Clean_up_photo_directory/clean_up_photo.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import os
|
||||||
|
from os.path import join
|
||||||
|
for (dirname, dirs, files) in os.walk('.'):
|
||||||
|
for filename in files:
|
||||||
|
if filename.endswith('.txt') :
|
||||||
|
thefile = os.path.join(dirname,filename)
|
||||||
|
size = os.path.getsize(thefile)
|
||||||
|
if size == 2578 or size == 2565:
|
||||||
|
print 'T-Mobile:',thefile
|
||||||
|
#os.remove(thefile) Add this when you are sure to delete the file
|
||||||
|
continue
|
||||||
|
fhand = open(thefile,'r')
|
||||||
|
lines = list()
|
||||||
|
for line in fhand:
|
||||||
|
lines.append(line)
|
||||||
|
fhand.close()
|
||||||
|
if len(lines) == 3 and lines[2].startswith('Sent from my iPhone'):
|
||||||
|
print 'iPhone:', thefile
|
||||||
|
#os.remove(thefile) Add this when you are sure to delete the file
|
||||||
|
continue
|
Loading…
Reference in New Issue
Block a user