Jump to content

How can I make code that selects all .jpg files in a folder in Windows Explorer.


Go to solution Solved by KaFu,

Recommended Posts

Posted

Hi my friends,

How can I make code that selects all .jpg files in a folder in Windows Explorer.

Reference image attached

 

 

snapshot 01.jpg

  • Solution
Posted

The example zip in this excellent UDF by @LarsJ contains all required includes.

 

This code will select all jpgs in the topmost Windows Explorer window.

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

Opt("MustDeclareVars", 1)

Example()

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

    ; Get an IShellBrowser interface
    GetIShellBrowser($hExplorer)
    If Not IsObj($oIShellBrowser) Then
        MsgBox(0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating.")
        Return
    EndIf

    ; Get other interfaces
    GetShellInterfaces()

    ; Get all items with full path
    Local $aFiles = GetItems(False, True)
    ; _ArrayDisplay( $aFiles, "All files" )
    For $i = 0 To UBound($aFiles) - 1
        If StringRight($aFiles[$i], 4) = ".jpg" Then SetSelectedItem($i)
    Next

EndFunc   ;==>Example

 

Posted
13 hours ago, KaFu said:

The example zip in this excellent UDF by @LarsJ contains all required includes.

 

This code will select all jpgs in the topmost Windows Explorer window.

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

Opt("MustDeclareVars", 1)

Example()

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

    ; Get an IShellBrowser interface
    GetIShellBrowser($hExplorer)
    If Not IsObj($oIShellBrowser) Then
        MsgBox(0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating.")
        Return
    EndIf

    ; Get other interfaces
    GetShellInterfaces()

    ; Get all items with full path
    Local $aFiles = GetItems(False, True)
    ; _ArrayDisplay( $aFiles, "All files" )
    For $i = 0 To UBound($aFiles) - 1
        If StringRight($aFiles[$i], 4) = ".jpg" Then SetSelectedItem($i)
    Next

EndFunc   ;==>Example

 

Thank you my friend.

How can I put the route I need in this code?

Posted
1 hour ago, Jos said:

What is wrong with Ctrl+A ?

CTRL+A selects ALL files, not just .jpg's. :D

Some guy's script + some other guy's script = my script!

Posted
14 hours ago, Jos said:

What is wrong with Ctrl+A ?

I can't use Ctrl+A because there are different files in each folder

Posted
14 hours ago, Jos said:

What is wrong with Ctrl+A ?

I can't use Ctrl+A because there are different files in each folder

Posted
On 6/23/2024 at 8:58 AM, KaFu said:

The example zip in this excellent UDF by @LarsJ contains all required includes.

 

This code will select all jpgs in the topmost Windows Explorer window.

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

Opt("MustDeclareVars", 1)

Example()

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

    ; Get an IShellBrowser interface
    GetIShellBrowser($hExplorer)
    If Not IsObj($oIShellBrowser) Then
        MsgBox(0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating.")
        Return
    EndIf

    ; Get other interfaces
    GetShellInterfaces()

    ; Get all items with full path
    Local $aFiles = GetItems(False, True)
    ; _ArrayDisplay( $aFiles, "All files" )
    For $i = 0 To UBound($aFiles) - 1
        If StringRight($aFiles[$i], 4) = ".jpg" Then SetSelectedItem($i)
    Next

EndFunc   ;==>Example

 

Thanks a lot, i used this code and working fine

This code work with the active windows explorer

Best regards

  • 4 weeks later...
Posted

Hello,

in case you finally want to have the JPG files collection in your clipboard, take a look at the fuction _ClipPutFile()

This one has the advantage, that you can even put multiple files into the clipboard, that are spread across multiple folders.

 

CU, Rudi.

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Posted
6 hours ago, rudi said:

Hello,

in case you finally want to have the JPG files collection in your clipboard, take a look at the fuction _ClipPutFile()

This one has the advantage, that you can even put multiple files into the clipboard, that are spread across multiple folders.

 

CU, Rudi.

 

Thanks a lot for your tip

best regards

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...