Joesephlebon
asked on
Batch file to comment specific lines into a text file
Hi Experts,
Happy cristmas for all, and hope we find all the happiness, health and money (lotof money $$$) :D
Please, i need to do a batch file like that :
MyBatchFile.bat file.txt FileWithLineToComment.txt
Where :
FileWithLineToComment.txt
it's a text file, this one containall the lines text (not numbers of line) that we need to comment.
MyFile.txt:
Containe all the lines
MyBatchFile.bat
Is the program that i need to write. This batch file will :
1- open FileWithLineToComment.txt, and read line by line
2- for each line we read, we will search it into the "MyFile.txt"
3- one time we find it we will add " // " in the first of the find line, and like that it will be
comment.
Exemple :
MyFile.txt Containe :
if i do this command line :
MyFile.txt will be like that:
Hope you can help me
Thanks
Happy cristmas for all, and hope we find all the happiness, health and money (lotof money $$$) :D
Please, i need to do a batch file like that :
MyBatchFile.bat file.txt FileWithLineToComment.txt
Where :
FileWithLineToComment.txt
it's a text file, this one containall the lines text (not numbers of line) that we need to comment.
MyFile.txt:
Containe all the lines
MyBatchFile.bat
Is the program that i need to write. This batch file will :
1- open FileWithLineToComment.txt,
2- for each line we read, we will search it into the "MyFile.txt"
3- one time we find it we will add " // " in the first of the find line, and like that it will be
comment.
Exemple :
MyFile.txt Containe :
123
34
12
153
123
757
FileWithLineToComment.txt12
757
if i do this command line :
MyBatchFile.bat file.txt FileWithLineToComment.txt
MyFile.txt will be like that:
123
34
//12
153
123
//757
Hope you can help me
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks so much Experts ;)
It's work fine :)
It's work fine :)
Welcome, glad that was useful.
~bp
~bp
Are there any blank lines etc. in the file that are important?
And just to check it seems you are checking the whole line to comment, i.e. if your string was found part way across the line.
If all of those end up being just like your answer it is a relatively simple for loop but no point writing that if not.
thanks
Steve