Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

biterScripting - Removing text between 2 points

Jan 22, 2012 3:56PM PST

Hello,

I am looking for some help. I am new to this, so please forgive me if i seem a bit dumb.

I
am looking for a script to remove text between 2 points (e.g.
<id>9999XX</id> becomes <id></id>), in multiple
.nfo files, in multiple sub-folders. The text to be removed is different
in each file.

I am trying to accomplish this using biterScripting but i am open to suggestions if you have another way.

I have got the following so far, but it replaces only specific text.


# Script nfoIDremove.txt
# .nfo files are in folder C:\nfo tester & it's sub-folders. I collect a list of them.
var str list ; lf -n -r "*.nfo" "C:\nfo tester" > $list
# Process files one by one.
while ( $list <> "")
do
# Get the next file.
var str file ; lex "1" $list > $file
# Read file contents into a string variable.
var str content ; cat $file > $content
# Keep replacing "testing" with "tested" until there are
# no more instances left of "testing".
while ( { sen -c "^testing^" $content } > 0 ) sal "^testing^" "tested" $content > null
# All instances are replaced. Write file back.
echo $content > { echo $file }
done

Now this allows me to change text in multiple .nfo files in multiple sub-folders.
However,
i only allows me to replace specific text. I need it to remove any
text between 2 'markers' (<id>[color=#FF0000]the_text_here[/color]</id> will become <id></id&gtWink This is where i am stuck.

Any help would be appreciated Many Thanks

Discussion is locked