Parse first/last character in batch

April 6, 2009 at 06:03:36
Specs: Windows 2003
Can anyone help come up with a solution.

I'm trying to simply parse the quotes from strings read in from a file. Each string starts and ends with a quote ("). I just want to drop the first and last character. I do not want to drop any quote nested inside the string.


See More: Parse first/last character in batch

Report •

April 6, 2009 at 06:30:39
:: drop first and last char

@echo off > newfile & setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%a in (myfile) do (
set str=%%a
set str=!str:~1,199!
set str=!str:~0,-1!
echo !str!>> newfile

If at first you don't succeed, you're about average.


Report •

April 6, 2009 at 17:52:56
if you can download tools like sed for windows (check my sig), then this is all you need
c:\> sed -i.bak "s/\"//g" file

Unix Win32 tools | Gawk for Windows

Report •

Related Solutions

Ask Question