-
January 22nd, 2012, 04:58 PM #1Junior Member
- Join Date
- Jan 2012
- Posts
- 2
biterScripting - Remove text between 2 points
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.
I have got the following so far, but it replaces only specific text.
Now this allows me to change text in multiple .nfo files in multiple sub-folders.
# 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
However, i only allows me to replace specific text. I need it to remove any text between 2 'markers' (<id>the_text_here</id> will become <id></id>) This is where i am stuck.
Any help would be appreciated
Many Thanks
BD
-
February 26th, 2012, 01:13 PM #2Junior Member
- Join Date
- Feb 2009
- Posts
- 4
biterscript to remove selective text between markers in multiple files
BD,
I had the same problem. I solved it by using their sample script SS_RemoveTags http://www.biterscripting.com/helppa...emoveTags.html
Updated script (portion I changed is in ORANGE).
# 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
# Remove all text between "<id>" and "</id>".
script SS_RemoveTags.txt input($content) start_tag("<id>") end_tag("</id>") > $content
# All instances are replaced. Write file back.
echo $content > { echo $file }
done
I will admit this is not my original code. I just put 2 and 2 together. Why reinvent the wheel ?
PatrickLast edited by PatrickMc; February 26th, 2012 at 04:11 PM.
-
February 26th, 2012, 08:24 PM #3Junior Member
- Join Date
- Jan 2012
- Posts
- 2
Hi Patrick,
Thank you for your reply. I have actually already solved this issue but using PowerShell.
Here is the code (PowerShell) if you are interested:
Much shorter script, you have got love PowerShell for that.
$movies = Get-ChildItem C:\nfo tester\ -include *.nfo -recurse
foreach ($movie in $movies)
{
(Get-Content $movie) -replace '<id>.*</id>','<id></id>' | Out-File ($movie.fullname) -encoding utf8
}
I will also note that this script also keeps the utf8 encoding. If you are using Boxee, utf8 is required apparently.
Thanks again for your reply.
BD
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
no remove button in add/remove programs
By keitkeit in forum Applications and Operating SystemsReplies: 7Last Post: April 3rd, 2011, 03:35 AM -
javascript: remove text after focus change
By ric_the_red in forum Webmastering and ProgrammingReplies: 0Last Post: July 16th, 2008, 10:15 AM -
LARGE TEXT > small text ?
By ClubMed in forum General Tech DiscussionReplies: 0Last Post: April 12th, 2005, 07:29 AM -
changing text in text boxes
By Carl-cox- in forum Webmastering and ProgrammingReplies: 3Last Post: March 20th, 2003, 02:57 PM -
How do you remove the left over garbage when you remove hardware in XP?
By darrelld in forum Applications and Operating SystemsReplies: 4Last Post: December 8th, 2001, 09:29 PM



LinkBack URL
About LinkBacks



Reply With Quote

Hello MMA Fan's..WelCome to Watch UFC 160 Live Stream: Antonio Silva vs Cain Velasquez Live Streaming (for UFC heavyweight title) Exciting & biggest MMA match on your Pc from MGM Grand Garden Arena...
~!@!Hello Guys Enjoy UFC 160 Live...