Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def line_trim(s):
- return s.split()[0]
- dir = '/home/caveat/tmp/'
- flist = os.listdir(dir)
- for i in flist:
- fullname = os.path.join(dir,i)
- if os.path.isfile(fullname) and not i.endswith('.txt'):
- f = open(fullname,'r')
- np = fullname + '.txt'
- g = open(np,'w')
- for j in f.readlines():
- g.write(line_trim(j)+'\n')
- g.close()
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement