- <#
- .SYNOPSIS
- Finds duplicates in the GD archive – A script
- for New Year’s eve!
- .DESCRIPTION
- .NOTES
- File Name : Count-GDDuplicate.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2
- .LINK
- http://pshscripts.blogspot.com/2010/12/count-gdduplicateps1.html
- .EXAMPLE
- Psh[Cookham8]>C:\foo\Count-GdDuplicate.ps1
- Count-GDDuplicate.ps1 - v 1.0.1
- 99 shows have duplicates
- 109 shows are duplicates of others
- #>
- ###
- # Start of Script
- ##
- # Constants:
- # $GDDiskRoot - where to find shows
- # $DeadShowBase - folder at top of gd shows
- $GDDiskRoot = "M:"
- $DeadShowBase = $GDDiskRoot + "\gd"
- # Announce Ourselves
- "DuplicateCount.ps1 - v 0.0.1"
- "+---------------------------------+"
- "! Find Duplicate Shows : $DeadShowBase !"
- "+---------------------------------+"
- ""
- # Get start time
- $starttime = Get-Date
- set-strictmode -off
- # Get the Dead shows
- $Dir = ls $DeadShowBase | where {$_.psiscontainer}
- $DeadShows = $Dir.count
- if ($DeadSHows -le 0) {"no shows found - check constants"; return}
- # So here look for duplicates.
- $shows =@{}
- $j = 0
- foreach ($show in $dir){
- $j++
- $showdate = $show.name.substring(0,10)
- if ($shows.$showdate) {
- $shows.$showdate++
- }
- else {
- $shows += @{$showdate=1}
- }
- }
- $shows = $shows.getenumerator() | Sort name
- $totaldups = 0
- $totaldupshows = 0
- foreach ($show in $shows){
- if ($show.value -gt 1) {
- # "{1} copies of: {0}" -f $show.name, $show.value
- $totaldups++
- $totaldupshows += $show.value - 1 # anything after the 1st is a dup
- }
- }
- # Display Summary
- "{0} shows have duplicates" -f $totaldups
- "{0} shows are duplicates of others" -f $totaldupshows
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Friday, 31 December 2010
Count-GDDuplicate.ps1
Monday, 2 February 2009
Updates on A Grateful Dead PowerShell Script
I really love mixing two of my favourite things: the good old Grateful Deal and PowerShell. I’ve posted a couple of scripts that examine my live show archive. Yesterday, I was able to spend some time updating my Count-GDSHows script. In Count-GDShows2.ps1, I added a couple of features. First I worked out how many shows are recording using the SHN format and how many in FLAC (plus how many are not noted in the folder name). Second, I timed the script, although the timing varies widely thanks to disk caching!
My GD (and my Jerry Garcia) archive is stored on a couple of external USB disks. I have separated Jerry shows from GD shows and have both stored on disks plugged into separate machines. I use the folder name of each show to define the date, type (aud vs sbd) and encoding format. So a show in “gd69-04-22.sbd.clugston.68.sbeok.shnf” is a soundboard encoded in the Shorten format, for a show on April 22 1969. Were you even alive then?
I wonder how many of this blog’s readers collect Grateful Dead shows? I have a standing offer that I’ll repeat: If you want the shows in my collection, send me a big disk and I’ll xcopy!
Sunday, 1 February 2009
Count-GDShows2.ps1
- <#
- .SYNOPSIS
- Counts the Grateful Dead shows in my archives and displays
- details of the collection.
- .DESCRIPTION
- This script looks at my GD archive, and uses folder names to
- determine show type (aud, sbd, etc), and checks to see what
- shows have checked MD5s. The script also times itself.
- This is an update to an earlier script that adds separate
- counts for FLAC and SHN shows.
- .NOTES
- File Name : Count-GDShows2.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- http://pshscripts.blogspot.com/2009/02/count-gdshows2ps1.html
- .EXAMPLE
- PS C:\foo> Count-GDShows2.ps1
- Count.ps1 - v 2.0.2
- +---------------------------+
- ! Dead Show Base : M:\gd !
- +---------------------------+
- Grateful Dead Show Summary
- --------------------------
- Total shows: 1146
- Soundboards: 800
- Auds : 70
- Unknown : 29
- Partial : 9
- SHN : 962
- FLAC : 137
- No coding : 47
- Broken : 4
- MD5's check: 489 (42.67 %)
- It took 0 minutes, 1 seconds
- #>
- ###
- # Start of Archive
- ##
- # Constants:
- # $GDDiskRoot - where to find shows
- # $DeadShowBase - folder at top of gd shows
- $GDDiskRoot = "M:"
- $DeadShowBase = $GDDiskRoot + "\gd"
- # Announce Ourselves
- "Count.ps1 - v 2.0.2"
- "+---------------------------+"
- "! Dead Show Base : $DeadShowBase !"
- "+---------------------------+"
- ""
- # Get start time
- $starttime = Get-Date
- # Count the Dead shows
- $Dir= ls $DeadShowBase | where {$_.psiscontainer}
- $DeadShows=$Dir.count
- if ($DeadSHows -le 0) {"no shows found - check constants"}
- #Create subsets based on names of the folders
- $deadsbds = $dir | where {$_.name -match ".sbd" }
- $deadbrkn = $dir | where {$_.name -match "broken" }
- $deadpart = $dir | where {$_.name -match "partial" }
- $deadauds = $dir | where {$_.name -match ".aud" }
- $deadunkw = $dir | where {$_.name -match ".unk"}
- # workout recording type
- $deadshn = $dir | where {$_.name -match ".shn"}
- $deadflac = $dir | where {$_.name -match ".flac"}
- $deadnocoding = $dir | where {$_.name -notmatch ".shn" -and $_.name -notmatch ".flac"}
- #and see how many have the md5ok's file?
- $DeadMD5Checked=0
- foreach ($d in $dir)
- {
- $sn=$d.fullname + "\md5check_ok"
- $md5ok= ls $sn -ea silentlycontinue
- if ($md5ok )
- {$DeadMD5Checked++}
- }
- # Get finishtime and calc elapsed
- $finishtime=Get-Date
- $executiontime = $finishtime - $starttime
- $min = $executiontime.minutes
- $sec = $executiontime.seconds
- #Display results
- "Grateful Dead Show Summary"
- "--------------------------"
- "Total shows: $deadshows"
- "Soundboards: $($deadsbds.count)"
- "Auds : $($deadauds.count)"
- "Unknown : $($deadunkw.count)"
- "Partial : $($deadpart.count)"
- "SHN : $($deadshn.count)"
- "FLAC : $($deadflac.count)"
- "No coding : $($deadnocoding.count)"
- "Broken : $($deadbrkn.count)"
- $DeadPctChecked=($DeadMD5checked/$DeadShows).tostring("P")
- "MD5's check: $DeadMD5checked ($DeadPctChecked)"
- "It took {0} minutes, {1} second(s)" -f $min,$sec
- ""
Saturday, 31 January 2009
Count-GDShows.ps1
- <#
- .SYNOPSIS
- Counts the Grateful Dead shows in my archives
- .DESCRIPTION
- This script looks at my GD archive, and uses folder names to
- determine show type (aud, sbd, etc), and checks to see what
- shows have checked MD5s
- .NOTES
- File Name : count-gdshows.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- http://pshscripts.blogspot.com/2009/01/count-gdshowsps1.html
- .EXAMPLE
- PS C:\foo> count-gdshows.ps1
- Count.ps1 - v 2.0.1
- +---------------------------+
- ! Dead Show Base : M:\gd !
- +---------------------------+
- Grateful Dead Show Summary
- --------------------------
- Total shows: 1146
- Soundboards: 800
- Auds : 70
- Unknown : 29
- Partial : 9
- Broken : 4
- MD5's check: 489 (42.67 %)
- #>
- ###
- # Start of Archive
- ##
- # Constants:
- # $GDDiskRoot - where to find shows
- # $DeadShowBase - folder at top of gd shows
- $GDDiskRoot = "M:"
- $DeadShowBase = $GDDiskRoot + "\gd"
- # Announce Ourselves
- "Count.ps1 - v 2.0.1"
- "+---------------------------+"
- "! Dead Show Base : $DeadShowBase !"
- "+---------------------------+"
- ""
- # Count the Dead shows
- $Dir= ls $DeadShowBase | where {$_.psiscontainer}
- $DeadShows=$Dir.count
- if ($DeadSHows -le 0) {"no shows found - check constants"}
- #Create subsets based on names of the folders
- $deadsbds=$dir | where {$_.name -match ".sbd" }
- $deadbrkn=$dir | where {$_.name -match "broken" }
- $deadpart=$dir | where {$_.name -match "partial" }
- $deadauds=$dir | where {$_.name -match ".aud" }
- $deadunkw=$dir | where {$_.name -Match ".unk"}
- #and see how many have the md5ok's file?
- $DeadMD5Checked=0
- foreach ($d in $dir)
- {
- $sn=$d.fullname + "\md5check_ok"
- $md5ok= ls $sn -ea silentlycontinue
- if ($md5ok )
- {$DeadMD5Checked++}
- }
- #Display results
- "Grateful Dead Show Summary"
- "--------------------------"
- "Total shows: $deadshows"
- "Soundboards: $($deadsbds.count)"
- "Auds : $($deadauds.count)"
- "Unknown : $($deadunkw.count)"
- "Partial : $($deadpart.count)"
- "Broken : $($deadbrkn.count)"
- $DeadPctChecked=($DeadMD5checked/$DeadShows).tostring("P")
- "MD5's check: $DeadMD5checked ($DeadPctChecked)"
- ""