batch file - Substring in a list of entries -
i have variable contains list of filenames , based on extension, need perform different action. not able extract extension inside loop
set binaries=file1.dll fil2.dll fil3.sys :: each file in list of binaries %%g in (%binaries%) ( :: if extension dll if /i [%%g:~-4%]==[.dll] ( echo dll file ) else ( echo sys file ) )
if condition failing. how correctly extract extension.
if /i "%%~xg"==".dll"
from cmd shell window for /?
:
in addition, substitution of variable references has been enhanced. can use following optional syntax: %~i - expands %i removing surrounding quotes (") %~fi - expands %i qualified path name %~di - expands %i drive letter %~pi - expands %i path %~ni - expands %i file name %~xi - expands %i file extension %~si - expanded path contains short names %~ai - expands %i file attributes of file %~ti - expands %i date/time of file %~zi - expands %i size of file %~$path:i - searches directories listed in path environment variable , expands %i qualified name of first 1 found. if environment variable name not defined or file not found search, modifier expands empty string modifiers can combined compound results: %~dpi - expands %i drive letter , path %~nxi - expands %i file name , extension %~fsi - expands %i full path name short names %~dp$path:i - searches directories listed in path environment variable %i , expands drive letter , path of first 1 found. %~ftzai - expands %i dir output line
Comments
Post a Comment