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 7950177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:11:24+00:00 2026-06-04T02:11:24+00:00

Im trying to split a file into sequential pages that are 8159 bytes long.

  • 0

Im trying to split a file into sequential pages that are 8159 bytes long. How can i read 8159 bytes of a file and save to the all!count! var? if the file is 8159 or less it reads the file and sets it to the !all! variable. How in the :split label can i read only so many bytes and save to variable.

@echo off
setlocal EnableDelayedExpansion EnableExtensions
for /f "tokens=*" %%a in ("newhtml.html") do set FileSize=%%~za
echo FileSize is %FileSize% bytes
if %FileSize% GTR 8159 goto split

SETLOCAL DisableDelayedExpansion 
set "all="
FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ newhtml.html"`) do (
    set "line=%%a"
    SETLOCAL EnableDelayedExpansion
    set "line=!line:#=#S!"
    set "line=!line:*:=!"
    for /F "delims=" %%p in ("!all!#L!line!") do (
        ENDLOCAL
        set "all=%%p"
    )
)
SETLOCAL EnableDelayedExpansion
if defined all (
set "all=!all:~2!"
set ^"all=!all:#L=^
[blank line, remove this comment]
[blank line, remove this comment]   
!"
set "all=!all:#S=#!"
)
echo the all variable is: !all!
goto end

:split
set count=0
set /a all_sub=%FileSize% / 8159
set /a all_rem=%FileSize% %% 8159
if %all_rem% NEQ 0 set /a all_ttl=%all_sub% + 1
echo %all_sub% full page(s), %all_rem% bytes(s) leftover, %all_ttl% total pages

for  %%a in ("newhtml.html") do (
    set /a count=count + 1
    echo Read 8159 bytes from this file newhtml.html, save to all!count!
    if !count! EQU %all_ttl% echo All done & goto end
)

goto end

:end

the section that needs help is the split label, and in the for loop that reads the file, how to get only 8159 bytes of data at a a time and write to sequential variables. i guess that i should make the !all! a function and then call it?

edit: i found this file (http://www.fourmilab.ch/splits/) to do the splits, short work to add it to the ALL routine to reassemble. many thanks dbenham and jeb!

  • 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-04T02:11:26+00:00Added an answer on June 4, 2026 at 2:11 am

    Why not simply read the file into an array?
    Each line would be one entry this works, if there isn’t any line with more than ~8190 characters.
    Then you didn’t need the replacing tricks for the linefeed and so on.

    But this depends of your actual problem.

    @echo off
    SETLOCAL DisableDelayedExpansion
    set "all="
    set count=0
    FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ aux1.txt"`) do (
        set "line=%%a"
        set /a count+=1
        SETLOCAL EnableDelayedExpansion
        set "line=!line:*:=!"
        for /F "delims=" %%p in (^"set "array[!count!]=!line!"^") do (
            ENDLOCAL
            %%p
        )
    )
    
    SETLOCAL EnableDelayedExpansion
    for /L %%n in (1 1 %count%) do (
      echo Line%%n:!array[%%n]!
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to import a CSV file into an array that I can use
I am trying to split this css file into different blocks. Everything matching /*@-
I'm trying to split an app.config file into multiple files to make it easier
I am trying to read file and split its line to get some context(Computer
i'm trying to read a file into my python program and apply tokenizer on
I have a function that parses a file into a list. I'm trying to
I am trying to split an RTF file into lines (in my code) and
I am trying to split up a large xml file into smaller chunks. I
I'm trying to split a Yahoo historical stock price csv file, downloaded into a
I am trying to split one big file into individual entries. Each entry ends

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.