Data file look:-
6 invoices. Each line represent 1 invoice data. Each column separated by | pipe.
7031982|BALANCE|000000 rent on 23/03/2019|0768|110241|385272|PETTY CASH OLAYAN|VENDOR|BPV2019-3|
7031986|BALANCE|000000|0768|226005|388883|\NOMAN\12\as\|EMPLOYEE|BPV2019-377|
7031986|BALANCE|000000|0768|226011|388883| NOMAN|EMPLOYEE|BPV2019-377|
7031986|BALANCE|000000|0768|240007|388883| NOMAN|EMPLOYEE|BPV2019-377|
7032003|BALANCE|000000|0703|231085|384173|WATER COMPANY|VENDOR|BPV2|
7032003|BALANCE|033511|0768|503000|384173|WäTER COMPANY|VENDOR|BPV2|
Requirement:- I need a bat file which will correct existing file
Some times we get the data like:-
1. |1797 \krv\Fice\AP\klo|
==> this should convert like || (just removing complete data within |)
2. |\krv\Finance\Finance\ap\INS12O|
==> this should convert like || (just removing complete data within |)
3. |\as\sa\1\as\|
==> this should convert like || (just removing complete data within |)
4. |second rent at cal on 23/05/2019|
==> this should convert like |second rent at cal on 23-05-2019| (just replace / with - )
5. | Johannes Märkl Monatsrechnung|
==> this should convert like | Johannes Markl Monatsrechnung | (just replace ä with a )
below is code
@echo off
setlocal enabledelayedexpansion
(for /f "delims=" %%a in (a30077889.txt) do (
set "line=%%a"
set "newline="
for %%b in ("!line:|=" "!") do (
set "token=%%~b"
if "!token:~0,1!"=="\" (
set "newline=!newline!|"
) else (
set "newline=!newline!%%~b|"
)
)
echo !newline:~0,-1!
))>a.new
REM move /y a.new a30077889.txt