Advertisement
unicodepepper

Untitled

Feb 22nd, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. f=open("gallerycount.txt","r")
  4.  
  5. mp4=open("mp4.txt","w")
  6. png=open("png.txt","w")
  7. jpg=open("jpg.txt","w")
  8. jpeg=open("jpeg.txt","w")
  9. mov=open("mov.txt","w")
  10. gif=open("gif.txt","w")
  11. other_lines=open('other_lines.txt','w')
  12.  
  13. i = True
  14. # i is the raw line reading - as long as it's not empty, the loop should continue
  15. # l is the text without indentation (stripped) - since strip takes out
  16. # newlines, I need to have them separate, to prevent the loop from stopping
  17. # because of an empty stripped newline
  18.  
  19. line_counter = 0
  20.  
  21. while i != "":
  22.     line_counter += 1
  23.     i=f.readline()
  24.     l=i.strip()
  25.     if l[-3:] == "MP4":
  26.         mp4.write(l+"\n")
  27.     elif l[-3:] == 'PNG':
  28.         png.write(l+"\n")
  29.     elif l[-3:] == 'JPG':
  30.         jpg.write(l+"\n")
  31.     elif l[-4:] == 'JPEG':
  32.         jpeg.write(l+"\n")
  33.     elif l[-3:] == 'MOV':
  34.         mov.write(l+"\n")
  35.     elif l[-3:] == 'GIF':
  36.         gif.write(l+"\n")
  37.     else:
  38.         other_lines.write(l+"\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement