My code so far:
for /F "tokens=*" %%A in (#opm.txt) do set str=%%A
set str=%str:~0,3%
@echo.%str% > #tags.txt
Basically, I have a huge list of things that I am attempting to take the first three letters from, however, I only end up getting one of those things from the list right now. For example:
The word ‘eagle’ is on the list. The end result should be EAG (and preferably in caps).
Any tips?
If you want to do more than one statement in a for loop you need to use brackets:
Note that opening bracket is in the same line as for … do … statement. In this case, you need to use delayed expansion to manipulate variables inside a loop (that makes variables enclosed with exclamation marks to be resolved in place):
Please also note that redirection syntax was changed from
>to>>. Single bracket redirection overwrites#tags.txtevery times statement is executed. Double bracket redirection appends lines at the end of the file (you may want to assure that the file is empty before the loop).Replacing capitalization of a letters in batch is fairly complicated without external tools. This is not a text-processing-friendly technology. Have you considered Python instead?