Sunday 11 November 2018

command line - How can I determine whether a Windows XP cmd variable ends with a given string?


I want to check on whether the last character(s) of an environment variable are \ or .exe. How can I do this in Windows XP SP3?



Answer



To use substrings:


set _parm1=foo.exe
if [%_parm1:~-1%]==[\] echo ends with \
if /i [%_parm1:~-4%]==[.exe] echo ends with .exe

You replace the number before the % sign to alter how many characters it checks at the end of the string.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...