I don't really want to muck about deleting folders on your system. But I have a script that should detect a chain with consecutive dupes if you select a folder below the dupes and press a hotkey.
It feeds the folders to a file manager. I have FreeCommander hard wired but you can change it to any file manager that will accept 2 folders on the command line.
As example, if you have c:\mydocs\mydocs\mydocs\docs
select "docs" in explorer and hit Shift-F8
FreeCommander should come up with c:\mydocs on one side and c:\mydocs\mydocs on the other. You would highlight the "docs" folder under c:\mydocs\mydocs and press F6 move.
If the hotkey routine does not detect a dupe chain it gives a sour "ding".
If it does it chimes so you now the file manager is coming up.
It's AutoIt3
#include <Sound.au3>
Global $terminalFolder = ""
Global $rootFolder = ""
Global $dirs[1]
Global $folders[1]
Global $x = 0, $y = 0
If Not HotKeySet("+{F8}", "ClipFolders") Then
MsgBox(0x1010, "DupeFolder", "Hot Key Set Failure: Please Choose a different Hotkey")
Exit
EndIf
While 1
Sleep(250)
WEnd
Func ClipFolders()
Send("^c")
Sleep(100)
$text = ClipGet()
If $text <> "" Then
$folders = StringSplit($text, @LF, 1)
If @error Then
$terminalFolder = $folders[1]
$dirs = StringSplit($terminalFolder, "\", 1)
If @error Then Return
$x = $dirs[0]
Do
$y = $x - 1
While $dirs[$y] = $dirs[$x]
$y -= 1
WEnd
If $y = $x - 1 Then
$x -= 1
$terminalFolder = BuildPath($x)
ContinueLoop
EndIf
$rootFolder = BuildPath($y + 1)
$terminalFolder = BuildPath($x)
ExitLoop
Until $x = 0
If $x > 0 Then
_SoundPlay("ok.wav")
ShellExecute("C:\Program Files\FreeCommander\FreeCommander.exe", $rootFolder & " " & $terminalFolder)
Else
_SoundPlay("fail.wav")
EndIf
EndIf
EndIf
EndFunc ;==>ClipFolders
Func BuildPath($arrayIndex)
Local $path = ""
For $i = 1 To $arrayIndex
$path &= $dirs[$i] & "\"
Next
Return _FileDirNoSlash($path)
EndFunc ;==>BuildPath
; Return Directory part of path without trailing slash
Func _FileDirNoSlash($path)
Return StringLeft($path, StringInStr($path, "\", 0, -1) - 1)
EndFunc ;==>_FileDirNoSlash
I included the .wav files or you can just comment out the sound play calls.