+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Junior 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.


    # 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>the_text_here</id> will become <id></id>) This is where i am stuck.

    Any help would be appreciated
    Many Thanks
    BD

  2. #2
    Junior 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 ?

    Patrick
    Last edited by PatrickMc; February 26th, 2012 at 04:11 PM.

  3. #3
    Junior 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:


    $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
    }
    Much shorter script, you have got love PowerShell for that.

    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

  1. no remove button in add/remove programs
    By keitkeit in forum Applications and Operating Systems
    Replies: 7
    Last Post: April 3rd, 2011, 03:35 AM
  2. javascript: remove text after focus change
    By ric_the_red in forum Webmastering and Programming
    Replies: 0
    Last Post: July 16th, 2008, 10:15 AM
  3. LARGE TEXT > small text ?
    By ClubMed in forum General Tech Discussion
    Replies: 0
    Last Post: April 12th, 2005, 07:29 AM
  4. changing text in text boxes
    By Carl-cox- in forum Webmastering and Programming
    Replies: 3
    Last Post: March 20th, 2003, 02:57 PM
  5. How do you remove the left over garbage when you remove hardware in XP?
    By darrelld in forum Applications and Operating Systems
    Replies: 4
    Last Post: December 8th, 2001, 09:29 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews