mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Search for text in all files and if matched move files to different folder and email

Author Message
sql_quest

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 12/10/2009
  • Status: offline
Search for text in all files and if matched move files to different folder and email Thursday, December 10, 2009 9:02 AM (permalink)
0
Hi All,

I have just started using powershell and came across a problem:

I have to search for a particluar word/s in all the files of a folder and if a word is matched that file should be moved to a different folder.

I have tried this

get-ChildItem  -include *.txt -recurse | select-String -pattern "Msg","Level"
and it gives me the correct output

test.sql.txt:1:Msg 156, Level 15, State 1, Server Line 2
test1.sql.txt:1:Msg 102, Level 15, State 1, Server Line 1

Now I want the above matched files moved to a different folder. How can I do this ?

Also, can I use Powershell to email those files to me ? I know this can be done, but need some help !

Thanks,
\\K
<message edited by sql_quest on Thursday, December 10, 2009 9:25 AM>
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.8
    mbt shoes www.wileywilson.com