I need to split up a very long line in a text file (maybe hundrerd thousands of characters) into shorter lines (8184 characters) and a .bat
cannot handle this task.
However, I found a PowerShell solution (here):
(gc in.txt) -replace ".{750}" , "$&`r`n" | sc out.txt
This works when I open up the PowerShell window and paste the slightly adjusted version, where 750
is 8184
and execute it, BUT when including it in my .bat
like this ...:
powershell -Command "(gc test.txt) -replace '.{8184}' , '$&`r`n' | sc temp.txt"
... it doesn't work as intended and inserts ...
`r`n
... after every 8184th character (I cannot inline format this, sry).
I tried to make use of:
powershell -Command "& {(gc test.txt) -replace '.{8184}' , '$&`r`n' | sc temp.txt}"
powershell -Command "(gc test.txt) -replace '.{8184}' , '$&\r\n' | sc temp.txt"
powershell -Command "(gc test.txt) -replace '.{8184}' , '$&VbCrLf' | sc temp.txt"
But I'm unable to make it work. What is the problem here?