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

  • Home
  • SEARCH
  • 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 9148103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:10:59+00:00 2026-06-17T11:10:59+00:00

I have over 5k text files in some folders. Now I need to only

  • 0

I have over 5k text files in some folders. Now I need to only remove "-" from the first line and last line in each text file.

I dont know how to do it, is there anyone who can help? what should i use to do this? vbs or normal batch

OS: Windows7

text file like this: 01.txt


% 01-A247M15 G70 

N0001 G30 G17 X-100 Y-100 Z0

N0002 G31 G90 X100 Y100 Z45

N0003 ; --PART NO.:  NC-HON.PHX01.COVER-SHOE.DET-1000.050

N0004 ; --TOOL:  8.55 X .3937 

N0005 D00 Q50 P01 +8.5500 ; TOOL DIA 

N0006 D00 Q51 P01 +0.3920 ; TOOL RAD 

N0007  % 01-A247M15 G70 

Please help.

  • 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-17T11:11:02+00:00Added an answer on June 17, 2026 at 11:11 am

    Use VBScript it’s simpler…

    First you parse the text file into an array: http://www.windowsitpro.com/content/content/46489/Listing_01.txt

    Function FileToArray(ByVal strFile, ByVal blnUNICODE)
      Const FOR_READING = 1
      Dim objFSO, objTS, strContents
    
    ' BEGIN CALLOUT A
      FileToArray = Split("")
    ' END CALLOUT A
    
      Set objFSO = CreateObject("Scripting.FileSystemObject")
    
      If objFSO.FileExists(strFile) Then
        On Error Resume Next
        Set objTS = objFSO.OpenTextFile(strFile, FOR_READING, False, blnUNICODE)
        If Err = 0 Then
          strContents = objTS.ReadAll
          objTS.Close
    ' BEGIN CALLOUT B
          FileToArray = Split(strContents, vbNewLine)
    ' END CALLOUT B
        End If
      End If
    End Function
    

    Then you do a REPLACE on the first and last row of the array and write it to another file, or the same file.

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

Sidebar

Related Questions

Like many, I have spreadsheet that draws data from over 40 text files as
I have this html file where I want to overlay some text over another.
I do have to deal with very large plain text files (over 10 gigabytes,
I have a a large text file (over 70mb) and need to count the
I have hundreds of thousands of small text files between 0 and 8kb each
I have ~300 text files that contain data on trackers, torrents and peers. Each
I have several csv files that I need to transfer over to mdb format.
I need a simple way to monitor multiple text log files distributed over a
I need to download from FTP over 5000 files being .html and .php files.
I have a text file that's appended to over time and periodically I want

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.