Solved

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

Posted on 2013-01-17
2
1,959 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 55

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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

729 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