Solved

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

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 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