Solved

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

Posted on 2013-01-17
2
1,800 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
2 Comments
 
LVL 51

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now