V
V
Vadim2019-08-15 11:14:39
batch processing
Vadim, 2019-08-15 11:14:39

How to correctly form a request in a bat script?

Good day!
You need to get the name of the first file and pass it to a variable when sorting by the third character of the file name.
There is a working version of the command that gives the correct output:
DIR /b /o "%folder%\%FiLE_MASK%" | SORT /+3 /R
The FOR loop only works like this:

for /f %%i in ('DIR /b /o "%folder%\%FiLE_MASK%"') do set filename=%%i

When you enter a complete command in a FOR loop, the script window closes:
for /f %%i in ('DIR /b /o "%folder%\%FiLE_MASK%" | SORT /+3 /R') do set filename=%%i

Help form the correct request!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question