0

Hello Dears,
I have hundereds of text
files and every file have thousand of
lines and there is only one word at each
line. My problem is that I want to add a
word with every word in files.
Example:
files contains a words
hello
dani
google
yahoo
Now I want to add a word with every word
like that:
hellodear
daniweb
googleisbest
yahoodotherest
if your understad my problem plz reply me
how can I edit all of my files bcoz
manually editing will take very long
times, bcoz there is about millions words
in all files.
Thanks in Advance.

4
Contributors
22
Replies
23
Views
10 Years
Discussion Span
Last Post by MidiMagic
0

Your example is too vague.

But you would need to write a program to do that. Give a better example and I could write it for you. (Maybe)

0

Thanks for reply, actually, I have thousands of text files and every file contains thousands of lines and there is only one word on each line. Now I want to add/attach one more word with every signle word in all files. For example there is a word in a file "dani" I want to convert it to "daniweb". So, like this I want to edit all my files.

It would be much appreciated if you make a programme/script for this solution.

Thanks & Regards.

0

How is it supposed to know which word to add?

Does it always add the same word when it finds a particular word? Or is the same word always added in the same place in the file?

Are the words to be added add in a list?

If you always need to add the same words in the same places in the file, you might be able to trick Excel into doing the job for you.

0

I already tried doing it with Excel, but I failed to do that, and Yes there is same single word which I want to add with every word in files.
Any other Trick ? Or Plz you try it to do with Excel or any other utility.

0

if all you need is to add a specific word to the end of each line (which contains one word ), then a batch file will suffice. An example

@echo off
for /F  %%i in (file.txt) do echo %%iweb

This will add the word "web" to the current lines

output:

C:\test>test.bat
helloweb
daniweb
googleweb
yahooweb

If you need different specific words for each line, then its a different story.

0

I get the error...

%%i was unexpected at this time

you got to run it in a batch file. If you run the for loop in a command shell, change %%i to %i
For ex, on command line

C:\test>@echo off
for /F  %i in (file.txt) do echo %iweb
helloweb
daniweb
googleweb
yahooweb
0

Yeah I just realised.

Why would you need to change the syntax for the bat file tho?

Isn't a batch (bat) file just a mirror of syntax you would use at the command prompt?

1

Yeah I just realised.

Why would you need to change the syntax for the bat file tho?

Isn't a batch (bat) file just a mirror of syntax you would use at the command prompt?

I did not change the syntax. Its how variables are defined in Windows batch shell.
If you open a command prompt and work your batch commands from there using for loops, you have to use %i (or some other alphabet) as the variable. If in a batch file , use %%i.. This is how windows batch work. You can also try it out. It will give error saying "syntax of the command is incorrect" when you use %i in a batch file.

0

Dear iamthwee your really done a great job, and I am really thankful to you for that task. Its working as I want to do.

0

Dear iamthwee however patch is working nice but its still taking a lot of time to editing text files, bcoz text files in diff folders and in every folder there is hundereds of files, and for editing I 1st copy file from one folder to another folder and then rename it to test and then apply patch and then cut it to another folder and again rename it and I repeat it for every signle file editing.

So, now can you plz add some more functionality by adding the patch edit all the files in signle folder and create a signle file or any named files in some other or same folder. I think this will save a lot of time instead of editing one by one file.

Hope you can do that. and I am waiting for your reply.

Thanks & Regards,

0

Yes I can do this so that it applies the patch to all your files (of any particular name) within a given folder.

Please wait 20 mins, because I have to program it...

0

Here we go...

Again, once you have downloaded it, right-click the folder and choose to extract all files.

When you run the patch it creates a new folder called:

NewFiles

In that folder will be your one text file.

0

Dear Iamthwee Thanks you very very much again.
And one more thing, is it create a duplicate free list or there may duplicate words existing ?. if yes, is it possible its create a duplicate free result file. ?

Thanks & Regards,

0

It doesn't eliminate duplicates in the text file.

But there are a variety of ways to do that. Implementing a hash table/map would be one such way (reasonably efficient).

Do you want me to do that for you. :)

0

Ok Dear, thanks for your co-operation.

May God give a success to you in this and hereafter world.

Thanks & Regards,

0

This would have been so easy in the old VW line editor. One command would have done it:

S/*/*addedword/*

I think edlin has similar powers. It's hiding in the MS-DOS part of XP.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.