Commit 2d2177ac authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

cuenta/elimina archivos vacios

parent 68beaf73
...@@ -6,6 +6,7 @@ os.chdir(newsDir) ...@@ -6,6 +6,7 @@ os.chdir(newsDir)
mediaLst = os.listdir('.') mediaLst = os.listdir('.')
mediaLst.sort() mediaLst.sort()
vacios_txt = open('vacios.txt','w')
empty_count = 0 empty_count = 0
for media in mediaLst: for media in mediaLst:
...@@ -20,15 +21,20 @@ for media in mediaLst: ...@@ -20,15 +21,20 @@ for media in mediaLst:
for file in fileLst: for file in fileLst:
fileSize = os.stat(file).st_size fileSize = os.stat(file).st_size
# print(media+'/'+year+'/'+file+' '+str(fileSize))
if not file.startswith('.') and fileSize <= 3: if not file.startswith('.') and fileSize <= 3:
empty_count += 1 empty_count += 1
print(media+'/'+year+'/'+file+' '+str(fileSize)) if empty_count == 1:
# os.system('rm '+file) vacios_txt.write(media+'/'+year+'/'+file+', '+'File size: '+str(fileSize))
else:
vacios_txt.write('\n'+media+'/'+year+'/'+file+', '+'File size: '+str(fileSize))
print(media+'/'+year+'/'+file+', '+'File size: '+str(fileSize))
os.system('rm '+file)
os.chdir('..') os.chdir('..')
os.chdir('..') os.chdir('..')
print('Archivos vacios: '+str(empty_count)) vacios_txt.write('\n'+'Total archivos vacios: '+str(empty_count)+'\n')
\ No newline at end of file vacios_txt.close()
print('Total 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