Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:00:51+00:00 2026-06-08T22:00:51+00:00

I have a load of text files with some html code in them. EG:

  • 0

I have a load of text files with some html code in them. EG:

Some random text....
..
...
....
<tag1>some more random text</tag1>
....
...
..

I need to run a script to go through each text file and move each line between the tags to a new text file in the same folder, and remove them from the original.

So the end result would be one file with no <tag1> and another file with only <tag1>.

I hope I made myself clear enough. Is this at all possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:00:52+00:00Added an answer on June 8, 2026 at 10:00 pm

    IF (and that is a big, bolded, italicized, capitalized IF) you can guarantee that each <tag1>...</tag> tag appears on a single line with no other content on that same line, and there are no tag attributes to complicate things, then the answer is easy.

    Edit – fixed a number of bugs, it actually works now 🙂

    @echo off
    for %%F in (*.txt) do (
      echo processing %%F
      findstr /rc:"^ *<tag1>.*</tag1> *$" "%%F" >"%%~nF.tag1%%~xF"
      findstr /rvc:"^ *<tag1>.*</tag1> *$" "%%F" >"%%~nF.new%%~xF"
      >nul move /y "%%~nF.new%%~xF" "%%F"
    )
    

    The solution could be extended to handle tag attributes fairly easily.

    But I seriously doubt your problem is really that simple. Valid HTML content can have a tag spread accross many lines, and there can be many tags on one line.

    Windows native batch is pretty lousy at text processing in general, and even worse for HTML or XML. I strongly recommend getting a third party tool like gnu sed for Windows that has robust text processing. Or better yet, get a tool that is specifically designed to process HTML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have (basically) this code - <script type=text/javascript language=javascript> $(document).ready(function() { $(#loadDiv).load(mypage.html, function(){ alert($(#someText).text())
Some people have told me that the following code is bad for HTML validation:
I have this simple ajax code, for some reason it wont load content onto
I have the following file file: <html> <head> <title></title> <script type=text/javascript src=/Prototype.js></script> <script type=text/javascript>
I'm trying to load text of all divs that have a particular class into
i have tried to to load the data to text box, while selecting the
I have a few HTML files that I'd like to include via tags in
I have the following javascript into a index.php file: <script type=text/javascript> $('.showpics, .showpics2').live('click', function()
I have an html page that calls some javascript and jQuery functions and also
I have some images in a SQL Server database. I want to display them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.