Windows batch split long string by length 64
I have tried to figure this out without any luck. Can anyone help on this?
I have a file: input.txt This file contains a long string - and i want to split the long string into 64 long string chunks, and save the content to a different file.
I don't have much so far, i know i have to use the for loop:
echo off set /p base64=<input.txt for /f "%base64:~0,64%" %%G IN %base64% DO echo %%G
But how to make the loop for each 64 characters in line - and in a batch script?
Any help will be appreciated.
@ECHO OFF SETLOCAL ( FOR /f "delims=" %%i IN (input.txt) DO SET longline=%%i&call:breakit )>output.txt GOTO :eof :breakit ECHO %longline:~0,64% SET longline=%longline:~64% IF DEFINED longline GOTO breakit GOTO :EOF
This should do what you want - but it may depend on the content of the file as batch has sensitivities to certain characters.