Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

advanced search for keywords in windows

Posted on 2013-12-17
7
Medium Priority
?
153 Views
Last Modified: 2014-01-02
I have a folder on a windows 2008 r2 server file share containing 300 text documents. i need to filter the number of text documents to just those that contain the word "back". Can anyone think of a way to do this, ideally to copy the files that contain back to a seperate folder or something?
0
Comment
Question by:pma111
  • 5
  • 2
7 Comments
 
LVL 19

Accepted Solution

by:
jss1199 earned 1500 total points
ID: 39724035
See the below vbs script.  copy to notepad and save as .vbs. Change C:\folder and C:\users\xxx\desktop to paths of your choice.

setlocal enabledelayedexpansion
for /r C:\folder %%a in (*.txt) do (
find "back" "%%a"
if !errorlevel!==0 copy "%%a" "C:\users\xxx\Desktop" /y
)

Open in new window

0
 
LVL 3

Author Comment

by:pma111
ID: 39724041
Thanks. Can you explain what it is doing as I am not a scripter?

What folder is it copying the results too?

And say if you have 1 txt document that contains that word say 5 times, does it copy the file 5 times, or just once?
0
 
LVL 19

Expert Comment

by:jss1199
ID: 39724059
In the second line, you will see that it is searching C:\ folder for all text files (.txt).  In the third line, I;ve specified that all files containing the string "back" be copied to the path on line four - "C:\users\xxx\Desktop".

Copies from: C:\folder
Copies to: C:\users\xxx\Desktop

If a file has multiple instances of "back", only one file will be copied.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Author Comment

by:pma111
ID: 39724065
Will give it a go! Thanks
0
 
LVL 3

Author Comment

by:pma111
ID: 39724084
i amended the paths accordingly, it as filtered.vbs and opened command prompt

ran the following command

cscript filtered.vbs (hit enter)

and the error states "expected identifier"? Any ideas?
0
 
LVL 3

Author Comment

by:pma111
ID: 39726073
any feedback to the error message provided?
0
 
LVL 3

Author Comment

by:pma111
ID: 39728936
are you still monitoring this one?
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

916 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