Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jan 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Extract data from multiple html files into 1 file

    Hi,

    I'm a Front-end developer, was trying to accomplish this with some Js+node with no success. Maybe It's simpler than I think.

    My problem is: I have several HTML files that I need to extract the exact same lines from each and condense into a .txt file.

    Example:
    example.jpg
    So, extract lines 2 to 4 from each html file and output all into one single txt


    Is there a way to do this with PS ?

    Thank you!

  2. #2
    Lounger
    Join Date
    Dec 2009
    Location
    Gillingham, Dorset, UK
    Posts
    33
    Thanks
    0
    Thanked 13 Times in 11 Posts
    Try this:


    Code:
    # Change this to the path where the HTML files are stored
    $path = 'C:\My_HTML_Files\*'
    # The extracted text will be appended to the output file (if it already exists)
    $outputFile = 'C:\Result.txt'
    
    Get-ChildItem -Path $path -Filter *.html |
    ForEach-Object {
    	$null, $txt = (Get-Content -Path $_.FullName -TotalCount 4).Trim()
    	Add-content -Path $outputFile -Value $txt
    }
    Last edited by Cliff.H; 2019-01-23 at 00:03.
    Cliff

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •