editing text files

Windows xp 2007
June 3, 2009 at 05:35:43
Specs: Windows XP, 2
Hi
i want to change some words in a text file with script or bat

example: change all "ab" words to "ba" in file1.txt then write new file into file2.txt

is this possible? is there anybody help me?


See More: editing text files

Report •


#1
June 3, 2009 at 19:22:53
if you have Python on Windows
for line in open("file"):
    line=line.strip().split()
    for n,item in enumerate(line):
        if item == "ab":
            line[n]="ba"
    print ' '.join(line)


Report •
Related Solutions


Ask Question