Question

I have a .bat file that allows to the User to enter full File name (full Path) and I`m wondering if it is possible to validate if the user is entered for example .bak file?

Was it helpful?

Solution

example:

set /p "FullPathNameData=Please enter the full path name of backup file for YourBackup: "
for /f "delims=" %%a  in ("%FullPathNameData%") do set "Extension=%%~xa"
if /i "%Extension%"==".bak" (echo %FullPathNameData% is a BAK file) else %FullPathNameData% is NOT a BAK file
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top