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.
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.
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.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments