Can I use a batch file to hilight a specific file format?

Mr. Mendelli

I've been experimenting with batch files lately, and recently I found an answer to an old question: Hilight/select a file with a batch script. Now that I have accomplished that, I would like to know if the same method can be used with a format variable (i.e. *.txt). More specifically, I would like to create a script to do the same for image files like .jpg, and .png that searches for all specified formats in a given disk, or path. This is the template I used:

%SystemRoot%\explorer.exe /select, "%TARGET%"

I have already tried simply placing the variables *.jpg and *.png in the place of %TARGET% both with, and without quotation marks. I am also well aware that this could take a tremendous amount of time given the ammount of images, computer performance, ect... Any help is appreciated.

IT Thug Ninja

Can I use a batch file to highlight a specific file format?

You most certainly can use a batch script to select all (or highlight all) files with a specific file extension that are all in the same one folder using sendkeys and cscript as the below example.

Batch Script Example

Be sure to change the value of the SET Extension= and the SET Folder= variables to be what you need those to be to suffice for the need.

Please note that if you want to search for multiple file extensions with this method, then the variable value of the SET Extension= variable should have each extension separated by OR for example if you want to see TXT, PDF, and BMP files, you'd use SET Extension=*.txt OR *.pdf OR *.bmp.

@ECHO ON

SET Folder=C:\Users\User\Desktop\Test
SET Extension=*.txt
:::SET Extension=*.txt OR *.pdf OR *.bmp
EXPLORER "%Folder%"

:VBSDynamicBuild
SET TempVBSFile=%temp%\~tmpSendKeysTemp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>"%TempVBSFile%"
ECHO Wscript.Sleep 900                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{F3}"                             >>"%TempVBSFile%"
ECHO Wscript.Sleep 900                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys "%Extension%"                      >>"%TempVBSFile%"
ECHO Wscript.Sleep 900                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 2}"                          >>"%TempVBSFile%"
ECHO Wscript.Sleep 900                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys "^a"                               >>"%TempVBSFile%"

CSCRIPT //nologo "%TempVBSFile%"

EXIT

Note: The above script was tested with Windows 10. If you are using Windows 7, you need to be sure to use "{TAB 3}" rather than "{TAB 2}" so it presses the tab key three times.


Further Resources

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Hilight/select a file with a batch script

From Java

How can I use a batch file to write to a text file?

From Dev

How can I convert the complete file to a specific format?

From Dev

Can I use SOCKS5 in FTP batch file on Windows?

From Dev

Batch file to write filenames from a directory into a text file with specific format

From Dev

Create txt file from batch file with specific date format in it

From Dev

Can I run another batch file in the current batch file windows?

From Dev

Can I run another batch file in the current batch file windows?

From Dev

How can I call a batch file within another batch file?

From Dev

What player can I use to repeat a specific part of an audio file?

From Dev

How can I change the system date format using a batch file/script?

From Java

How can I echo a newline in a batch file?

From Java

How can I pass arguments to a batch file?

From Dev

How can I convert this vbs into a batch file?

From Dev

How can I run this batch file?

From Dev

Can I slow down the speed of a batch file?

From Dev

I can't convert a JSON format file into a python format file

From Dev

Is there a native "file explorer" in Qt that I can use to have the user select path to a specific file?

From Java

Can I reference the batch file directory in a WinSCP batch script?

From Dev

How can I retrieve a file path for file of a specific file extension?

From Dev

can i send answer to binary file with batch file

From Dev

Using a batch file, can I rename files within a ZIP file?

From Dev

can i send answer to binary file with batch file

From Dev

How can i check file name form is number by batch file?

From Dev

How can I use nested quotes when calling a powershell script within a batch file?

From Dev

How can i use dos batch file to get a list of folders in a folder and convert it into a javascript array?

From Dev

How can I use nested quotes when calling a powershell script within a batch file?

From Dev

How can i use dos batch file to get a list of folders in a folder and convert it into a javascript array?

From Dev

How can I use a batch shortcut to open multiple Windows Explorer folders, and a Notepad file?

Related Related

  1. 1

    Hilight/select a file with a batch script

  2. 2

    How can I use a batch file to write to a text file?

  3. 3

    How can I convert the complete file to a specific format?

  4. 4

    Can I use SOCKS5 in FTP batch file on Windows?

  5. 5

    Batch file to write filenames from a directory into a text file with specific format

  6. 6

    Create txt file from batch file with specific date format in it

  7. 7

    Can I run another batch file in the current batch file windows?

  8. 8

    Can I run another batch file in the current batch file windows?

  9. 9

    How can I call a batch file within another batch file?

  10. 10

    What player can I use to repeat a specific part of an audio file?

  11. 11

    How can I change the system date format using a batch file/script?

  12. 12

    How can I echo a newline in a batch file?

  13. 13

    How can I pass arguments to a batch file?

  14. 14

    How can I convert this vbs into a batch file?

  15. 15

    How can I run this batch file?

  16. 16

    Can I slow down the speed of a batch file?

  17. 17

    I can't convert a JSON format file into a python format file

  18. 18

    Is there a native "file explorer" in Qt that I can use to have the user select path to a specific file?

  19. 19

    Can I reference the batch file directory in a WinSCP batch script?

  20. 20

    How can I retrieve a file path for file of a specific file extension?

  21. 21

    can i send answer to binary file with batch file

  22. 22

    Using a batch file, can I rename files within a ZIP file?

  23. 23

    can i send answer to binary file with batch file

  24. 24

    How can i check file name form is number by batch file?

  25. 25

    How can I use nested quotes when calling a powershell script within a batch file?

  26. 26

    How can i use dos batch file to get a list of folders in a folder and convert it into a javascript array?

  27. 27

    How can I use nested quotes when calling a powershell script within a batch file?

  28. 28

    How can i use dos batch file to get a list of folders in a folder and convert it into a javascript array?

  29. 29

    How can I use a batch shortcut to open multiple Windows Explorer folders, and a Notepad file?

HotTag

Archive