1

Topic: sbstring (right) - cmd

All greetings! There is a file c a name, for example mrsdsft_16052018.xlsx It is known that in the end of file name there will be _ character - and date. The length of a file can be different. It is necessary means cmd to create a variable = 2018-05-16.
I am more with bases I work, there it would be easy. We find digit position _ and further we cut substring 8 characters, we break them and all. In cmd is that  similar - help ?

2

Re: sbstring (right) - cmd

help set

3

Re: sbstring (right) - cmd

Dimitry Sibiryakov;
Understood

4

Re: sbstring (right) - cmd

medoed;
I will lift a subject, revealed in the course of a spelling - !
Prompt please, I try  value of variables in a cycle in cmd, does not work!
How to rewrite truly?
for %% var in (1 2 3 4) do (
set tvar = %% var
echo %tvar %
)

5

Re: sbstring (right) - cmd

medoed wrote:

How to rewrite truly?

To throw out tvar, to deduce immediately var.

6

Re: sbstring (right) - cmd

Dimitry Sibiryakov;
No, I will work then about it as a variable. To select substrings etc.
I  wrote a simple loop.
The question remains in force how to initialize  in a cycle, in command line?
Thanks!

7

Re: sbstring (right) - cmd

To initialize in their cycle easily. To use then in their cycle difficult. Meditate on
Difference between %var % and! var!.

8

Re: sbstring (right) - cmd

echo off
for %% v in (1 2 3 4) do (
call:Foo %% v
)
goto end
:Foo
set z = % 1
echo %z %
goto:eof
:End

(C) StackOverflow

9

Re: sbstring (right) - cmd

Leonid Kudryavtsev wrote:

echo off
for %% v in (1 2 3 4) do (
call:Foo %% v
)
goto end
:Foo
set z = % 1
echo %z %
goto:eof
:End

(C) StackOverflow

Super, thanks that is necessary! It is a little for itself adapted, with reassignment in a method

echo off
for %% v in (1 2 3 4) do (
call:Fval %% v
)
goto End
:Fval
set z = % 1
set/A z = % z % + 10
echo %z %
:End