My purpose of storing multiple strings in array is because I wrote a batch script to read text files. If specified word is detected inside the text file, it will store a string to an array. After go through multiple text files (it will be multiple strings in the array), I would like to echo out all the strings inside the array and email to specified person. After go through many post and all I saw was set myarray[0]=abc
or the array already declared manually.
Here is my code :
@echo off
setlocal EnableDelayedExpansion
(
for %%x in (
C:\Users\310152922\Desktop\Mohit_Task\AutomatedScript\COB\sucess.txt
) do for /f "usebackq delims=" %%a in ("%%~fx") do (
set "str=%%a"
set "part1=!str:~0,10!"
set "part2=!str:~11,8!"
set "part3=!str:~20,4!"
-------------------------------------------------------------------
**I wanted to set an array here (Do not want manually set the string) **
**If the "NoneFolder" word detected, store the string into array**
if "!part1!" == "NoneFolder" (
echo No Folder **<< Wanted to store this**
)
if "!part1!" == "Downloaded" (
echo Downloaded
)
** If the "EmptyFiles" word detected, store string into array **
if "!part1!" == "EmptyFiles" (
echo No files **<< Wanted to store this**
)
** Echo the array here **
------------------------------------------------------------------
)
)>"C:\Users\310152922\Desktop\Mohit_Task\AutomatedScript\COB\email.txt"
pause
Expected Output:
After for loop, the array should got No folder
and No files
.
FYI, this is a monitoring script that wrote to scan through the multiple text files. So I need it(array) to collect multiple strings and echo out and EMAIL to user.
P.s. Any posts regarding on how to email to a user to share =)? If there's any question please do ask me!
Edit(Additional): Tell you guys about my task
My task is to loop through the log files. While going through each line, if keyword detected it should email that whole line information to the user(i do not know how to hold the string and email all the stored string to user, Impossible each time keyword detected and it will send one email. Then my user will mad at me...) So I have the idea maybe I can do it on array. I totally can't think other way besides array =/.
Thanks for viewing, comments and answers. Please explain to me! Thanks!