Petri.co.il forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Windows Scripting > General Scripting
Petri.co.il is happy to award RicklesP the title of Most Valuable Member !!!
Register Calendar Calendar Search Petri IT Knowledgebase Forums Search Todays Posts Today's Posts Mark Forums Read
Notices

DOS Batch to Find String in All Files

DOS Batch to Find String in All Files

this thread has 1 replies and has been viewed 7149 times

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 16th August 2012, 18:25
trwhalen trwhalen is offline
Casual
Casual
 
 Join Date: Aug 2012
  6 month star 12 month star
 Posts: 2
 Reputation: trwhalen is on a distinguished road (10)
Default DOS Batch to Find String in All Files

Hi,
I'm struggling with the correct DOS Batch commands (XP and W7) to find a specific character "@" in any and all text files in one directory and to count those occurences. Here's what I've got, but still returning 0 count. If I put a specific file name in the FOR command, it WILL count any "@" that it finds. But doesn't seem to work with "." or "*.*) in the fileset parm which should cause the FOR command to read thru ALL files. I'm trying to display the found tokens with the %%G but that doesn't work. Not necessary, just for debugging. Any help is very appreciated.

Code:
REM Find and count all files with email addresses
REM Assume any user_data record with @ is valid email address
FOR /F "delims=@ eol=`" %%G IN (.) DO (CALL :CHECK %%G)
echo (
echo Number of Emails Sent = %count%
echo (
GOTO :eof
 
:CHECK %%G
set _DataIn=%%G
echo CHECK %_DataIn%
set /a count+=1
GOTO :eof

Last edited by Rems; 16th August 2012 at 18:32.. Reason: added [CODE] tags
  #2  
Old 16th August 2012, 22:35
trwhalen trwhalen is offline
Casual
Casual
 
 Join Date: Aug 2012
  6 month star 12 month star
 Posts: 2
 Reputation: trwhalen is on a distinguished road (10)
Default Re: DOS Batch to Find String in All Files

I think I've found it:

Code:
 
findstr /R /N "@" *.* | find /c ":"
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: input data to a string/remove the string leaving only the data using batch file Slow DOS Command Shell 1 23rd September 2011 14:55
Batch file to filter and rename string in txt file Antediluvian DOS Command Shell 2 2nd July 2010 10:51
Batch Script: Delete files based on files listed in a text document Fr0stb1t3 DOS Command Shell 7 6th May 2010 11:00
Batch Scripting - how to read a string value from a text file albert_newton General Scripting 2 6th August 2009 19:44
Find string in .txt from a list of computers Lan General Scripting 4 11th September 2007 12:03


All times are GMT +3. The time now is 17:39.

Steel Blue 3.5.4 vBulletin Style ©2006 vBEnhanced
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
 

Valid XHTML 1.0!   Valid CSS!

Copyright 2005 Daniel Petri