Last active
June 3, 2025 11:45
-
-
Save curability4apish/96c2f1bb45426afac7cf2761ff73b9f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
rem Manually define the Downloads folder path here | |
set "downloadsFolder=D:\Downloads" | |
rem Check if the path is valid | |
if not exist "!downloadsFolder!" ( | |
echo Error: The specified folder does not exist. | |
goto :end | |
) | |
:main | |
cls | |
echo Listing all .exe and .zip files in the specified Downloads folder (newest to oldest): | |
set "count=0" | |
for /f "tokens=*" %%F in ('dir "!downloadsFolder!\*.exe" "!downloadsFolder!\*.zip" /b /a-d /o-d /t:c 2^>nul') do ( | |
set /a count+=1 | |
echo !count!. %%F | |
set "file[!count!]=%%F" | |
) | |
rem Check if any .exe or .zip files were found | |
if %count%==0 ( | |
echo No .exe or .zip files found in the Downloads folder. | |
goto :list_other_files | |
) | |
rem Prompt user to select a file | |
echo. | |
echo Press 0 to list other files (e.g., .docx, .mp4) in the Downloads folder. | |
set /p "choice=Enter the number of the file you want to select: " | |
if %choice%==0 ( | |
goto :list_other_files | |
) | |
set "selectedFile=!file[%choice%]!" | |
rem Validate the user's choice | |
if "!selectedFile!"=="" ( | |
echo Invalid selection. | |
goto :main | |
) | |
goto :process_file | |
:list_other_files | |
cls | |
echo Listing other files in the specified Downloads folder (newest to oldest): | |
set "count=0" | |
for /f "tokens=*" %%F in ('dir "!downloadsFolder!\*" /b /a-d /o-d /t:c 2^>nul ^| findstr /v /i /e ".exe .zip"') do ( | |
set /a count+=1 | |
echo !count!. %%F | |
set "file[!count!]=%%F" | |
) | |
rem Check if any other files were found | |
if %count%==0 ( | |
echo No other files found in the Downloads folder. | |
goto :main | |
) | |
rem Prompt user to select a file from the additional list | |
echo. | |
echo Press 0 to go back to the previous menu. | |
set /p "choice=Enter the number of the file you want to select: " | |
if %choice%==0 ( | |
goto :main | |
) | |
set "selectedFile=!file[%choice%]!" | |
rem Validate the user's choice | |
if "!selectedFile!"=="" ( | |
echo Invalid selection. | |
goto :list_other_files | |
) | |
goto :process_file | |
:process_file | |
set "filePath=!downloadsFolder!\!selectedFile!" | |
echo Selected File Path: !filePath! | |
rem Check if the file exists | |
if not exist "!filePath!" ( | |
echo Error: The selected file does not exist. | |
goto :main | |
) | |
rem Calculate the MD5 hash and output to temp.txt | |
certUtil -hashfile "!filePath!" MD5 > temp.txt | |
rem Read the output and find the line that contains the actual hash | |
set "hash=" | |
for /f "skip=1 tokens=*" %%A in (temp.txt) do ( | |
if not defined hash ( | |
set "hash=%%A" | |
) | |
) | |
rem Remove trailing spaces from the hash | |
for %%A in (!hash!) do set "hash=%%A" | |
rem Check if hash is set | |
if not defined hash ( | |
echo Error: Could not calculate the hash. | |
goto :main | |
) | |
echo Hash: !hash! | |
rem Open the URL in the default web browser | |
start https://www.virustotal.com/gui/file/!hash! | |
del temp.txt | |
goto :main | |
:end | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simplified version.