Before everyone says use Perl or POWERSHELL - I cant.
I have a business need that requires me to develop a batch script to remove instances of the ' symbol from a text file as it's preventing a process from loading into our target systems. The catch is, however, the ' only needs to be removed if it's the second character in a string.
For example
Import File
DOS'
DO'S
D'OS
New File
DOS'
DO'S
D OS
I've written a peice of code that removes ALL instances of the ' symbol so I just need help amending it to only remove it if it's the second character in a string. Here is my code:
Code: Select all
@echo off
setlocal EnableDelayedExpansion
REM This is to allow for variable editing within the for loop
for /f "delims=" %%A in (test1.txt) do (
REM This loops through each line in test.txt
REM and performs everything within () to the line
REM which is held in %%A
set a=%%A
echo !a:'= ! >>newfile.txt
REM this adds the line to newFile.txt replacing every instance of " with no character
)
Any help is greatly appreciated! Thanks!