- <#
- .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
Technorati Tags: Grateful Dead