Filter Out Filename from Full Path String

Author Message
lizaoreo

  • Total Posts : 13
  • Scores: 0
  • Reward points : 0
  • Joined: 1/31/2008
  • Location: Calhoun, GA
  • Status: offline
Filter Out Filename from Full Path String Wednesday, November 24, 2010 3:18 AM (permalink)
0
[Helpful answer received] / [List Solutions Only]
I'm working on filter job results for some jobs that run robocopy to pull out the currently copying file.  Currently, I've got to the point that I can list the most recent file copying as shown in the sample script below.  Unfortunately, I can't for the life of me figure out how to cut out the data I want from that point.  My results are coming back like this:

C:\WINDOWS\source\I386\SM59W.DL_
C:\WINDOWS\source\I386\SM81W.DL_
C:\WINDOWS\source\I386\SM87W.DL_
C:\WINDOWS\source\I386\SM89W.DL_
C:\WINDOWS\source\I386\SM8AW.DL_

I'm wanting something more like this:

SM59W.DL_
SM81W.DL_
SM87W.DL_
SM89W.DL_
SM8AW.DL_

 
 $job = {robocopy C:\ C:\test /e /L /nS /nc /ndl} 
$jobs = start-job $job 
start-sleep -seconds 3 function Get-LatestResult ($results) 
    { 
    $lresults = $results.length - 1 
    $output = $results[$lresults] 
    return $output 
    }   while (Get-Job -State "Running") { 
$results = (Receive-Job -job $jobs) 
Get-LatestResult $results 
start-sleep -seconds 1 
}

 
I know this one has to be simple, probaby using Trim or something, I figure I can use the last "\" as a filter, but I can't seem to single it out and cut out the rest.
 
#1
    lizaoreo

    • Total Posts : 13
    • Scores: 0
    • Reward points : 0
    • Joined: 1/31/2008
    • Location: Calhoun, GA
    • Status: offline
    Re:Filter Out Filename from Full Path String Monday, November 29, 2010 3:52 AM (permalink)
    0
    Think I've solved my problem using the string split method.
     
     function Get-LatestResult ($results)
     {
     $lresults = $results.length - 1
     $path = $results[$lresults]
     $path = $path.split("\")
     $lpath = $path.length - 1
     $output = $path[$lpath]
     return $output
     } 

     
    #2
      TomRiddle

      • Total Posts : 620
      • Scores: 12
      • Reward points : 0
      • Joined: 2/7/2008
      • Location: Australia
      • Status: offline
      Re:Filter Out Filename from Full Path String Tuesday, November 30, 2010 3:54 PM (permalink)
      0
      [This post was marked as helpful]
      This works for me :)
       
      function Get-LatestResult ($results)

         split-path $results -leaf 
      }
      -join([int[]][char[]]'Ut|jwXmjqq%Wzqjx'|%{[char]($_-5)})
       
      #3
        anytua34i

        • Total Posts : 9
        • Scores: 0
        • Reward points : 0
        • Joined: 1/24/2011
        • Status: offline
        Re:Filter Out Filename from Full Path String Monday, January 24, 2011 7:13 PM (permalink)
        0
        When the 3 morning arrived new york escort the Druids would give new york asian escort a piece of wood new york escorts from their fires to each family,then they would take them home to start new cooking fires.These new york asian escorts fires would keep the homes warm and free from evil
         
        #4

          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.9