Batch file to replace semicolons in text files with tildes.

I have text files in a folder (C:\tracking).  I would like a batch file that will do a find and replace ove all the text inside the files that will change all of the semicolons (;) with the tilde (`).  

I'm trying to get to files delimited with tildes (vendor import file requirement) from a system that will export files only with semicolons as delimters.

Can anyone help?  (I've looked at almost every post in this place - going on 3 hours of trying now....I give up!!)

Who is Participating?
Julian HansenConnect With a Mentor Commented:
I don't think this easily doable in a batch file without some external utility like SED

Alternatively there are apps out there that will do this for you.

If using vb or vbscript is an option, this may be pretty easy...

BTW, this is a tilde:  ~

Doing a find and replace is beyond the scope of batch files.  What you can do instead is to write a very simple program, be it in C, VB, and write a batch file to process each of the exported files.

Also, when changing how a data file is delimited, i'd be very carefull, as the original program expects and handles the semicolon... so if you change all the ; to ', then if there are any occurances of the ' in the files, you're converted data will be corrupt.
tmhechlerAuthor Commented:
I found two that I put together that worked.  However, it will work on XP, but not on Win 2000.  Any suggestions?

*****************begin batch file***********************

@echo off
SET replace=
FIND /V "&" < import.dat> toproc.dat
FOR /F "tokens=1 delims=" %%i IN (toproc.dat) DO (
  SET replace=%%i

FIND "&" < import.dat >>importnew.txt
DEL toproc.dat
:: MOVE /Y importnew.txt import.dat

ECHO %replace:;=~%>>importnew.txt


*****************end batch file*********************
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.