advanced search for keywords in windows

Posted on 2013-12-17
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?
Question by:pma111
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
  • 5
  • 2
LVL 19

Accepted Solution

jss1199 earned 500 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


Author Comment

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?
LVL 19

Expert Comment

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.
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.


Author Comment

ID: 39724065
Will give it a go! Thanks

Author Comment

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?

Author Comment

ID: 39726073
any feedback to the error message provided?

Author Comment

ID: 39728936
are you still monitoring this one?

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

627 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