Replace text in different line

Microsoft Windows xp professional w/serv...
July 5, 2010 at 08:33:44
Specs: Windows XP
Hi everybody
I would like to create a batch file or vbs file that do this task:
In each text file on desktop (*.txt)
I would like to replace in the first line: , by ; and the following line: ," by ;" .
I tried to find something that answer my question on this forum and google but i don't find any suitable option that may fix my problem.

thank you


See More: Replace text in different line

Report •


#1
July 5, 2010 at 08:51:22
I use a cool freeware utility for jobs like this:

http://www.bulkrenameutility.co.uk/

Failing that, if you want your own macro, I would turn to AutoHotKey for this kind of thing and not VB.


Report •

#2
July 5, 2010 at 09:46:37
That software rename my file. I want to replace string into it.
But it look to be a good freeware for those you want to do that.

Report •

#3
July 5, 2010 at 11:59:24
@echo off >new & setlocal enabledelayedexpansion
pushd %userprofile%\bureau
for /f "tokens=*" %%a in ('dir /b *.txt') do (
set xx=0
for /f "usebackq tokens=*" %%b in ("%%a") do (
set /a xx+=1
if !xx! lss 3 (
set bb=%%b
set bb=!bb:~,=;!
>> new echo !bb!
) else (
>> new echo %%b
)
)
move /y new "%%a"
)
::------ end
(not tested)

Report •

Related Solutions

#4
July 5, 2010 at 12:17:19
Thank you for your fast replay.
'cause we are in a french environement, i used Bureau instead of Desktop but i don't have any Error that show me why it does not work.

do you have any idea !?


Report •

#5
July 5, 2010 at 21:33:14
One thing, i forgot to increment xx! I figure that there are many more errors, but try using modified resp#3 where i fixed my dumb oversight.

Report •

#6
July 6, 2010 at 05:15:00
thank you for your reply.
Now my text file is converted to:
Commande ECHO d‚sactiv‚e. :(

Report •

#7
July 6, 2010 at 10:38:23
could you post the first two lines of the file (or a close facsimile thereof?)

Report •

#8
July 6, 2010 at 10:44:30
It's for importing into Access:
here the lines that you asked for:
Code Site,Num Reseau Article,Mnemo Reseau,Code Article,Qte Articles,Mnt Total Ventes,Code Article/ Num Article
"D--058007","1","R.C","TRAM5E1006","2","224","TRAM5E1006 / 6313"

Report •

#9
July 6, 2010 at 21:08:00
I misread your original post, apologies. You want , replaced with ; in both lines 1 and two (apparently to make csv fields into one field?)
try again resp. #3.

Report •

#10
July 7, 2010 at 05:23:36
Many thanks for your help.
The code transfort my text file from that:
Code Site,Num Reseau Article,Mnemo Reseau,Code Article,Qte Articles,Mnt Total Ventes,Code Article/ Num Article
"D--058007","1","R.C","TRAM5E1006","2","224","TRAM5E1006 / 6313"
"D--078038","15","LAU","A100115107","3","111","A100115107 / 7936"
To That:
bb:~,=;
bb:~,=;
"D--078038","15","LAU","A100115107","3","111","A100115107 / 7936"
"B--001547","15","LAU","A100115332","34","0","A100115332 / 8046"

any idea ?


Report •


Ask Question