Code: Select all
for /F %%a in ('find /c /v "" ^< fileList.txt') do set files=%%a
Aacini is redirecting the list file that contain the file names as it will be the file where the "FIND" command will search in,
In your example "10009", this will be assigned to
!nextNumber! variable, but the files name doesn't contain the number
1 so it must be removed and take only the rest of the numbers or you can just take the
first 4 numbers from the right ( and that what !nextNumber
:~-4! represent.
- sign means from the right.
4 number means the four characters in the variable.
Or you can excluded the
number 1 by using
!nextNumber:~1!that means to start from second character and take the rest.
The rule issuppose we have a variable
X has the value
1234now,
number 1 has index number
0 and
number 2 has index number
1 and
number 3 has index number
2 and
number 4 has index number
3so when you want to display number
1 and
2 -->
%x:~0,2%
That means take characters in
index 0 and
index 1 but not
index 2 [
till index 2 as
index 2 is not included]
To take all characters from let's say
number 2 and all the rest
%x:~1%You don't have to provide the end index.
But when using the - sign, you start from the right and the index then start from number 1 not 0.
I hope that is clear enough
What's a good source to learn batch writing?
This question was asked a lot
,
well, there is no particular source.
all what you need is to know is the basics of each command (
help in cmd window will give a start), and while coding your own batch files you will face obstacles and during your search for the answers you will get the experience and learn new tricks and advanced techniques.
I only knew the basics when i signed in this forum, but from practice and reading i learned.
I guess that is basically how every one here learned.