Solved

advanced search for keywords in windows

Posted on 2013-12-17
7
148 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
An article on effective troubleshooting
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…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

837 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