Solved

Batch file to find string in text file and if  the string exists, make text file

Posted on 2013-01-17
2
2,009 Views
Last Modified: 2013-01-17
I need a batch file to look through a text file named differance.txt. If there is a line in differance.txt that is "FC: no differences encountered" then I need to make a text file named "Downloaded.txt", if the line "FC: no differences encountered" is not in the differance.txt then I want to do nothing.
Thank you for the help,
Lori
0
Comment
Question by:NLITech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 56

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 38789912
I think this should do what you asked, let me know if you have questions.

@echo off
setlocal

REM Define files and search string
set Match=FC: no differences encountered
set SearchFile=difference.txt
set CreateFile=downloaded.txt

REM If the file to be created already exists, remove it
if exist "%CreateFile%" del "%CreateFile%" > NUL

REM If the search string is found in the file, create the new file
find /i "%Match%" "%SearchFile%" >NUL && echo.>"CreateFile"

Open in new window

~bp
0
 

Author Comment

by:NLITech
ID: 38789923
I think I got it.
echo off
CD /D "D:\PDFBills\logs
find /c "FC: no differences encountered" "D:\ logs\differance.txt"
if %errorlevel% equ 1 goto notfound
echo.>"D:\PDFBills\logs\downloaded.txt
goto done
:notfound
goto done
:done
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question