Saturday 31 January 2009

Count-GDShows.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Counts the Grateful Dead shows in my archives 
  4. .DESCRIPTION 
  5.     This script looks at my GD archive, and uses folder names to 
  6.     determine show type (aud, sbd, etc), and checks to see what 
  7.     shows have checked MD5s 
  8. .NOTES 
  9.     File Name  : count-gdshows.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 CTP3 
  12. .LINK 
  13.     http://pshscripts.blogspot.com/2009/01/count-gdshowsps1.html 
  14. .EXAMPLE 
  15.     PS C:\foo> count-gdshows.ps1 
  16.     Count.ps1 - v 2.0.1 
  17.     +---------------------------+ 
  18.     ! Dead Show Base  :  M:\gd  ! 
  19.     +---------------------------+ 
  20.  
  21.     Grateful Dead Show Summary 
  22.     -------------------------- 
  23.     Total shows:   1146 
  24.     Soundboards:   800 
  25.     Auds       :   70 
  26.     Unknown    :   29 
  27.     Partial    :   9 
  28.     Broken     :   4 
  29.     MD5's check:   489 (42.67 %) 
  30. #> 
  31. ### 
  32. # Start of Archive 
  33. ## 
  34.  
  35. # Constants: 
  36. # $GDDiskRoot    - where to find shows 
  37. # $DeadShowBase  - folder at top of gd shows 
  38.  
  39. $GDDiskRoot     = "M:" 
  40. $DeadShowBase   = $GDDiskRoot + "\gd" 
  41.  
  42. # Announce Ourselves 
  43. "Count.ps1 - v 2.0.1" 
  44. "+---------------------------+" 
  45. "! Dead Show Base  :  $DeadShowBase  !" 
  46. "+---------------------------+" 
  47. "" 
  48.  
  49. # Count the Dead shows 
  50.  
  51. $Dir= ls $DeadShowBase  | where {$_.psiscontainer} 
  52. $DeadShows=$Dir.count 
  53. if ($DeadSHows -le 0) {"no shows found - check constants"} 
  54.  
  55. #Create subsets based on names of the folders 
  56. $deadsbds=$dir | where {$_.name -match ".sbd" } 
  57. $deadbrkn=$dir | where {$_.name -match "broken" } 
  58. $deadpart=$dir | where {$_.name -match "partial" } 
  59. $deadauds=$dir | where {$_.name -match ".aud" } 
  60. $deadunkw=$dir | where {$_.name -Match ".unk"} 
  61.  
  62. #and see how many have the md5ok's file? 
  63.  
  64. $DeadMD5Checked=0 
  65. foreach ($d in $dir) 
  66. {  
  67.   $sn=$d.fullname + "\md5check_ok" 
  68.   $md5ok= ls $sn -ea silentlycontinue 
  69.   if ($md5ok )  
  70.      {$DeadMD5Checked++} 
  71.  
  72. #Display results 
  73.  
  74. "Grateful Dead Show Summary" 
  75. "--------------------------" 
  76. "Total shows:   $deadshows" 
  77. "Soundboards:   $($deadsbds.count)" 
  78. "Auds       :   $($deadauds.count)" 
  79. "Unknown    :   $($deadunkw.count)" 
  80. "Partial    :   $($deadpart.count)" 
  81. "Broken     :   $($deadbrkn.count)" 
  82. $DeadPctChecked=($DeadMD5checked/$DeadShows).tostring("P"
  83. "MD5's check:   $DeadMD5checked ($DeadPctChecked)" 
  84. "" 

No comments: