This question is related to this question: Batch: delete line feed from end of text file?
So I have a txt-file containing some information and I want to remove the last rows LFCR (line feed, carriage return) chars.
I need to point out the source file path and the destination file path using variables and the filename as a parameter (%1).
The batch code
@echo off
set @srcfile="D:\AgrCC\AgrTest\Report Results\%1"
set @dstfile="D:\AgrCC\AgrTest\Data Export\%1"
setlocal DisableDelayedExpansion
set "firstLineReady="
(
for /F "eol=$ delims=" %%a in (%@srcfile%) DO (
if defined firstLineReady (echo()
set "firstLineReady=1"
<nul set /p "=%%a"
)
) > %@dstfile%
But instead of removing the LFCR chars I end up with a file looking like this in the destination folder:
Destination file content
D:\AgrCC\AgrTest\Report Results\bg1baa.725