Solved

advanced search for keywords in windows

Posted on 2013-12-17
7
137 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 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

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
Why do Marketing keep bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

 
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 does your email signature look on mobiles?

Do your employees use mobile devices to reply to emails? With mobile becoming increasingly important to the business world, it is in your best interest to make sure that your email signature looks great across all types of devices.

Join & Write a Comment

Know what services you can and cannot, should and should not combine on your server.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

706 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

20 Experts available now in Live!

Get 1:1 Help Now