Commit eea7bd02 authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

cuenta/elimina archivos vacios

parent 356cc80b
import os
newsDir = '/home/geoint/virtualHDD/m3/noticias'
# newsDir = '/home/cna_service/noticias/'
os.chdir(newsDir)
mediaLst = os.listdir('.')
mediaLst.sort()
empty_count = 0
for media in mediaLst:
os.chdir(media)
yearLst = os.listdir('.')
yearLst.sort()
for year in yearLst:
os.chdir(year)
fileLst = os.listdir('.')
fileLst.sort()
for file in fileLst:
fileSize = os.stat(file).st_size
# print(media+'/'+year+'/'+file+' '+str(fileSize))
if not file.startswith('.') and fileSize <= 3:
empty_count += 1
print(media+'/'+year+'/'+file+' '+str(fileSize))
# os.system('rm '+file)
os.chdir('..')
os.chdir('..')
print('Archivos vacios: '+str(empty_count))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment