Amazing-Python-Scripts

Форк
0
/
Clean_Up_Photo_Directory.py 
20 строк · 824.0 Байт
1
import os
2
from os.path import join
3
for (dirname, dirs, files) in os.walk('.'):
4
    for filename in files:
5
        if filename.endswith('.txt'):
6
            thefile = os.path.join(dirname, filename)
7
            size = os.path.getsize(thefile)
8
            if size == 2578 or size == 2565:
9
                print 'T-Mobile:', thefile
10
                # os.remove(thefile) Add this when you are sure to delete the file
11
                continue
12
            fhand = open(thefile, 'r')
13
            lines = list()
14
            for line in fhand:
15
                lines.append(line)
16
            fhand.close()
17
            if len(lines) == 3 and lines[2].startswith('Sent from my iPhone'):
18
                print 'iPhone:', thefile
19
                # os.remove(thefile) Add this when you are sure to delete the file
20
                continue
21

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.