Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-17
2
Medium Priority
?
2,110 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 57

Accepted Solution

by:
Bill Prew earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

721 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