We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,628 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to concatenate lines in batch

I have an batch script that needs to concatenate several hundred of lines (72 chars) in one long line for base64 to decode. He used line reading because of the windows XP line limit (8191 chars per line).

The script currently has 2 issues at result:

It exports with 2xquote character between my 72 char lines (like so: "addf4534@$") and base64 doesn't like that
It creates several 2-3 lines extra. The last line being the correct one.

Here is the script (install.zip its what is going to be encoded for later decoding):

@echo off
CALL D:\utilities\base64.exe -e install.zip install.txt
set "string="
::call :concat with %%a between double quotes because the two equal characters at the end of the string won't be removed
set lines=0
for /f "tokens=1 delims=ΒΆ" %%a in (install.txt) do call :concat "%%a"
::now remove all double quotes from the string (safe because base64 doesn'd use double quotes in encoding)
set string=%string:"=%

echo %string%>>install_no_returns.txt
goto :eof
:concat
set /A lines+=1
echo %lines%
set "string=%string%%1"
pause
if %lines%==50 (
    set lines=0
    echo %string%
    set string=%string:"=%
    echo %string%>>install_no_returns.txt
    pause
    set "string="
)
goto :eof

Can you help me with fixing it? Thanks

1
Contributor
0
Replies
1
View
observ
Newbie Poster
23 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0514 seconds using 2.65MB