I want to write a batch file to store a character from a file name into a variable.
For example if my file name is helloworld
or how_are_you?
, I want to store fourth character from right into variable x
(which in the above cases would be o
and _
).
File names do not have spaces in my case.
Assuming the file name is stored in a variable called
filename
, you can do this:P.S
If you need
filename
to be passed as a command-line argument (for example, the first), use this before evaluatingrstr
andx
: