I do not know why the set command inside () won't show outside of its (). My test code is below:
Code: Select all
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
:loop
set fileLocate=
set /p fileLocate= Enter the file name:
if "%fileLocate%" EQU "" goto loop
if /i "%fileLocate:~-4%" EQU ".ext" (
echo file with ext
) ELSE (
echo Do not have ext and add it
set fileLocate = %fileLocate%.ext
)
echo %fileLocate%
Btw, does anyone has a code to create a path in case of the path input does not exist?
ps: I run this in cmd of Vista
ver= Microsoft Windows [Version 6.0.6000]
some examples here generated errors too.
Any adjustment needed in Vista cmd?
Thanks in advance,