Solved

Batch File - Replacing double quotes in a text file

Posted on 2004-06-30
2
1,368 Views
Last Modified: 2012-05-05
How can I replace double quotes in a text file using a batch file?

I've seen a couple of answers pointing to http://www.batchfiles.co.nr but the example there doesn't appear to work if the string you are looking to replace is ".

I thought I could do it by reading the contents of the file into a variable and then using SET, but I can't find out how to read the file into a variable.

Or can I use a FOR loop which looks at each line in the file as a whole, rather than splitting the line using delimiters?

Thanks,
Angie
0
Comment
Question by:angiemc1
2 Comments
 
LVL 30

Accepted Solution

by:
SteveGTR earned 125 total points
ID: 11438505
This batch file changes " to ' in the file passed on the command line. The results are written to output.txt.

@echo off

setlocal

if "%1"=="" echo Please enter file name&goto :EOF

if exist output.txt del output.txt > NUL

for /f "delims=" %%a in ('type %1') do call :PROCESS "%%a"

echo Output.txt has results
goto :EOF

:PROCESS

set line=%~1

REM Replace double quote with single quote
set line=%line:"='%

echo %line%>>output.txt

Good Luck,
Steve
0
 

Author Comment

by:angiemc1
ID: 11444509
Thanks, I'll give it a try
0

Featured Post

Announcing: The 13th Annual Expert Award Winners

Each year we recognize members for their outstanding contributions to our vibrant community in our Expert Awards. The winners receive a custom trophy recognizing their achievement. Join us in congratulating and thanking all of the top Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now