Sunday, 1 February 2009

Count-GDShows2.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Counts the Grateful Dead shows in my archives and displays 
  4.     details of the collection. 
  5. .DESCRIPTION 
  6.     This script looks at my GD archive, and uses folder names to 
  7.     determine show type (aud, sbd, etc), and checks to see what 
  8.     shows have checked MD5s. The script also times itself. 
  9.      
  10.     This is an update to an earlier script that adds separate  
  11.     counts for FLAC and SHN shows. 
  12. .NOTES 
  13.     File Name  : Count-GDShows2.ps1 
  14.     Author     : Thomas Lee - tfl@psp.co.uk 
  15.     Requires   : PowerShell V2 CTP3 
  16. .LINK 
  17.     http://pshscripts.blogspot.com/2009/02/count-gdshows2ps1.html
  18. .EXAMPLE 
  19.     PS C:\foo> Count-GDShows2.ps1 
  20.     Count.ps1 - v 2.0.2 
  21.     +---------------------------+ 
  22.     ! Dead Show Base  :  M:\gd  ! 
  23.     +---------------------------+ 
  24.  
  25.     Grateful Dead Show Summary 
  26.     -------------------------- 
  27.     Total shows:   1146 
  28.     Soundboards:   800 
  29.     Auds       :   70 
  30.     Unknown    :   29 
  31.     Partial    :   9 
  32.     SHN        :   962 
  33.     FLAC       :   137 
  34.     No coding  :   47 
  35.     Broken     :   4 
  36.     MD5's check:   489 (42.67 %) 
  37.     It took 0 minutes, 1 seconds 
  38.      
  39. #> 
  40. ### 
  41. # Start of Archive 
  42. ## 
  43.  
  44. # Constants: 
  45. # $GDDiskRoot      - where to find shows 
  46. # $DeadShowBase  - folder at top of gd shows 
  47.  
  48. $GDDiskRoot = "M:" 
  49. $DeadShowBase   = $GDDiskRoot + "\gd" 
  50.  
  51. # Announce Ourselves 
  52. "Count.ps1 - v 2.0.2" 
  53. "+---------------------------+" 
  54. "! Dead Show Base  :  $DeadShowBase  !" 
  55. "+---------------------------+" 
  56. "" 
  57. # Get start time 
  58. $starttime = Get-Date 
  59.  
  60. # Count the Dead shows 
  61.  
  62. $Dir= ls $DeadShowBase  | where {$_.psiscontainer} 
  63. $DeadShows=$Dir.count 
  64. if ($DeadSHows -le 0) {"no shows found - check constants"} 
  65.  
  66. #Create subsets based on names of the folders 
  67. $deadsbds   = $dir | where {$_.name -match ".sbd" } 
  68. $deadbrkn   = $dir | where {$_.name -match "broken" } 
  69. $deadpart   = $dir | where {$_.name -match "partial" } 
  70. $deadauds   = $dir | where {$_.name -match ".aud" } 
  71. $deadunkw   = $dir | where {$_.name -match ".unk"} 
  72. # workout recording type 
  73. $deadshn    = $dir | where {$_.name -match ".shn"} 
  74. $deadflac   = $dir | where {$_.name -match ".flac"} 
  75. $deadnocoding = $dir | where {$_.name -notmatch ".shn" -and $_.name -notmatch ".flac"} 
  76.  
  77. #and see how many have the md5ok's file? 
  78. $DeadMD5Checked=0 
  79. foreach ($d in $dir) 
  80. {  
  81.   $sn=$d.fullname + "\md5check_ok" 
  82.   $md5ok= ls $sn -ea silentlycontinue 
  83.   if ($md5ok )  
  84.      {$DeadMD5Checked++} 
  85.  
  86. # Get finishtime and calc elapsed 
  87. $finishtime=Get-Date 
  88. $executiontime = $finishtime - $starttime 
  89. $min = $executiontime.minutes 
  90. $sec = $executiontime.seconds 
  91.  
  92. #Display results 
  93.  
  94. "Grateful Dead Show Summary" 
  95. "--------------------------" 
  96. "Total shows:   $deadshows" 
  97. "Soundboards:   $($deadsbds.count)" 
  98. "Auds       :   $($deadauds.count)" 
  99. "Unknown    :   $($deadunkw.count)" 
  100. "Partial    :   $($deadpart.count)" 
  101. "SHN        :   $($deadshn.count)" 
  102. "FLAC       :   $($deadflac.count)" 
  103. "No coding  :   $($deadnocoding.count)" 
  104. "Broken     :   $($deadbrkn.count)" 
  105. $DeadPctChecked=($DeadMD5checked/$DeadShows).tostring("P"
  106. "MD5's check:   $DeadMD5checked ($DeadPctChecked)" 
  107. "It took {0} minutes, {1} second(s)" -f $min,$sec 
  108. "" 

No comments: