Solved Remove Carriage Return at End of File

May 4, 2016 at 12:39:32
Specs: Windows 7
I have this batch script that I wrote but what is happening is it is adding an extra carriage return after the footer is added.

@echo off

REM Message Class = COMRECIN
REM Pell
REM This batch file is used to add the appropriate header and trailer lines to COD files being sent to TDClient
REM Developer: Maria Lindquist
REM Created: February 25, 2016

:: set header and trailer values
set header=O*N05TG71900 ,CLS=COMRECIN,XXX,BAT=,
set footer=O*N95TG71900 ,CLS=COMRECIN,XXX,BAT=,

:: set path for files
set outpath=\\DISB_OUT\
set inpath=\\DISB_OUT\

::prompts the user for the next file extension number to use
set /p filenumber=COMRECIN_DISB - Enter file extension number:

::insert replace tab;
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -file NoTabs.ps1 -xmldir "%inpath%COMRECIN.xml"

::adds header to file
echo %header% > %outpath%COMRECIN.%filenumber%

::rename file
type %inpath%COMRECIN.xml >> %outpath%COMRECIN.%filenumber%

::adds footer to file
echo %footer% >> %outpath%COMRECIN.%filenumber%

::deletes file saved from FA so that it doesn't get SFTP'd w/o headers/trailers
del %inpath%COMRECIN.xml

See More: Remove Carriage Return at End of File

Report •

May 4, 2016 at 17:41:35
✔ Best Answer
The standard method for batch (and only that I know of):
rem for reference - echo %footer% >> %outpath%COMRECIN.%filenumber%
set out=%outpath%COMRECIN.%filenumber%
set /p=%footer%>>%out%<nul
::---- end snip
If already existing file to be appended, use: COPY /B file1 + file2

message edited by nbrane

Report •
Related Solutions

Ask Question