Python Forum
Updating a filesets contents
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating a filesets contents
#4
This is working okay.

#!/usr/bin/python3

import glob, os
os.chdir("/home/somepath")

for file in glob.glob("chunk*.txt"):
    print(file)
    open_file = open(file,'r')
    read_file = open_file.read()
    read_file = "<s> " + read_file + " </s> " + "(" + (file.replace(".txt" , ".wav" , 4))  + ")"
    write_file = open(file,'w')
    write_file.write(read_file)

    # Close file
    open_file.close()
Quote:chunk142.txt
<s> No the outcome will be completely different </s> (chunk-142.wav)
Reply


Messages In This Thread
Updating a filesets contents - by jehoshua - Mar-10-2018, 11:00 AM
RE: Updating a filesets contents - by wavic - Mar-10-2018, 11:52 AM
RE: Updating a filesets contents - by jehoshua - Mar-10-2018, 11:45 PM
RE: Updating a filesets contents - by jehoshua - Mar-11-2018, 12:50 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020