Removing double quotes from a text file?

July 5, 2011 at 08:26:17
Specs: Windows Vista
I am very new to MSDOS/batch files, but I have a question...

I have a text file (lets call it C:\myText.csv) and I am trying to remove all double quotes from the text file. myText.csv is a scheduled to be updated daily with new information, but the program which it gets its text includes double quotes around text values as well as around each row, and sometimes includes quadrouple quotes around text (e.g. """hello"",""world"",5").

Anyway, is there an easy way to eliminate the quotes? And if not, can someone help me with this code, or point me in the right direction?


See More: Removing double quotes from a text file?

Report •

July 5, 2011 at 08:47:54
Stated there is no DOS in Vista, the following NT batch does the job

@echo off & setlocal EnableDelayedExpansion
type nul > ""
for /F "delims=" %%A in ('type "myText.csv"') do (
  set row=%%A
  set row=!row:"=!
  echo.!row!>> ""
del "myText.csv"
ren ""  *.csv

Report •

July 5, 2011 at 10:17:29
Not sure how this ended up in Vista, sorry about that!
This code actually deletes everything...

maybe there is an issue with
set row=!row:"=!
my understanding of the set syntax is limited, but should it be %row:"=%?

Report •

July 5, 2011 at 10:36:54
First of all What OS are you running?

The script works in XP/Vista/7/2000 but NOT in Windows NT/4.0.

So stated the environment variable must be marked by ! inside a FOR loop due to Delayed Expansion rule.

Report •

Related Solutions

July 5, 2011 at 10:47:09
Here the NT/4.0 version

@echo off
type nul > ""
for /F "delims=" %%A in ('type "myText.csv"') do call :EDIT %%A
del "myText.csv"
ren "" *.csv
goto :EOF

set row=%*
set row=%row:"=%
echo.%row%>> ""
goto :EOF

Report •

Ask Question