Jump to content

Shortcut to select all files by extension type in Explorer


Recommended Posts

This script will make it so you can press Alt + "+" in Windows Explorer to select all files with the current file extension. This is something that I wanted for a long time and it should be a feature in Windows, but it's not. The only way to get close is to use the search thing (but then it shows the results excluding everything else) or to group by that type, but I don't want it grouped.

You can press Alt + Enter right after to open properties on those files or you can press delete to delete only files of that type.

You need the "Automating Windows Explorer" pack here: https://www.autoitscript.com/forum/topic/162905-automating-windows-explorer/


#include "Includes\AutomatingWindowsExplorer.au3"
#include <Array.au3>

Opt( "MustDeclareVars", 1 )

HotKeySet("!=", "SelectTypes")

Func SelectTypes()
   ; Windows Explorer on XP, Vista, 7, 8
   Local $hExplorer = WinGetHandle("[REGEXPCLASS:^(Cabinet|Explore)WClass$]")
   If Not $hExplorer Then
      MsgBox(0, "Explorer", "Could not find Windows Explorer.")

   $hExplorer = WinActive("[REGEXPCLASS:^(Cabinet|Explore)WClass$]")
   If Not $hExplorer Then
      MsgBox(0, "Explorer", "Windows Explorer is not in focus.")

   ; Get an IShellBrowser interface
   If Not IsObj($oIShellBrowser) Then
      MsgBox(0, "Explorer", "Could not get an IShellBrowser interface.")

   ; Get other interfaces

   ; Get selected files with full path
   ;GetFiles( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 )
   Local $aAllFiles = GetItems(False, False)
   Local $aFiles = GetItems(True, False)
   Local $sExt
   Local $i
   If UBound($aFiles) = 1 Then
      ;MsgBox(0, "Selected", $aFiles[0])
      $sExt = StringRight($aFiles[0], StringLen($aFiles[0]) - StringInStr($aFiles[0], ".", 0, -1))
      ;MsgBox(0, "Selected", $sExt)
      For $i = 0 To UBound($aAllFiles) - 1
         If StringInStr($aAllFiles[$i], ".") > 0 Then
            If StringRight($aAllFiles[$i], StringLen($aAllFiles[$i]) - StringInStr($aAllFiles[$i], ".", 0, -1)) = $sExt Then
      MsgBox($MB_ICONWARNING, "Error", "None or multiple items selected!")

While 1


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...