0

I'm new to programming .bat files. I need to create a batch file that deletes all "" in a txt file. For example, I would want the following:

"","","","01","","Dan",

to look like this:

,,,"01",,"Dan",

Any ideas?

  • Try this:- type file.txt | findstr /v "" – Rahul Tripathi Oct 04 '13 at 15:50
  • It is easier to do it in Powershell with `set-content`, Check this http://stackoverflow.com/questions/60034/how-can-you-find-and-replace-text-in-a-file-using-the-windows-command-line-envir – CS Pei Oct 04 '13 at 15:50

3 Answers3

1
setlocal enabledelayedexpansion
for /f "delims=" %%i in (file.txt) do set a=%%i&set a=!a:""=! &echo !a!>>new.txt

this will make a new file "new.txt" with the ""s removed. to over write the old file add this:
del a.txt&ren new.txt a.txt

cure
  • 2,588
  • 1
  • 17
  • 25
0

Use find and replace

Find "" and replace it with nothing (keeping 'replace with' box empty)

Yedhu Krishnan
  • 1,225
  • 15
  • 31
0

This uses a helper batch file called repl.bat from - http://www.dostips.com/forum/viewtopic.php?f=3&t=3855

Put repl.bat in the same folder as the batch file and text file, or you can type this at a cmd prompt in the folder with repl and the text file.

@echo off
type "file.txt" |repl.bat "\x22\x22" "" >"newfile.txt"
foxidrive
  • 40,353
  • 10
  • 53
  • 68