recursivley scan text files and move any files with line starting with matching

Welcome Forums General PowerShell Q&A recursivley scan text files and move any files with line starting with matching

Viewing 3 reply threads
  • Author
    Posts
    • #230716
      Participant
      Topics: 2
      Replies: 5
      Points: 14
      Rank: Member

      Hello We have severeal hundred robocopy log files that get written to a certain area, i believ get-content can perform what i need but unsude on the exacts to use here.  we want to:

       

      1, interogate several undred log files in (lets say for instance) d:\robologs

      2, if any of these files that have lines starting with any of the below 5 statments, then move that text file to d:\robolog\failed folder:

      Not enough quota is available to process this command.

      Access is denied.

      The process cannot access the file because it is being used by another process.

      An unexpected network error occurred.

      This file is currently not available for use on this computer.

      Thanks in advance

       

    • #230719
      Participant
      Topics: 5
      Replies: 2384
      Points: 6,066
      Helping Hand
      Rank: Community MVP

      James

      This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

      We expect you to make an own attempt to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

    • #230779
      Participant
      Topics: 2
      Replies: 5
      Points: 14
      Rank: Member

      thanks for your update,

       

      so I have searched and tried this:

      gci ‘z:\’ -Include “Not enough quota is available to process this command” | %{ Move-Item $_.FullName ‘z:\log\bad’ }

      however doesnt seem to be working, i think it should move any text files from z:\ to z:\log\bad if it contains the string “Not enough quota is available to process this command”

       

      I have run it but doesnt seem to move anything even though there are definatley files in z:\ that match this critera.

       

      Could you help with the syntax please?

    • #230806
      Participant
      Topics: 5
      Replies: 2384
      Points: 6,066
      Helping Hand
      Rank: Community MVP

      You should urgently learn the very basics of Powershell first. Without that you will not understand the help you get in forums like that. Please read the complete help for the cmdlets you’re about to use including the examples to learn how to use them. You may start with Get-ChildItem, Foreach-Object, Get-Content and about_if.

      Regardless of that: When you post code, error messages, sample data or console output format it as code, please.
      In the “Text” view you can use the code tags “PRE“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.
      Thanks in advance.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.