Hi, I need to create a batch which will read a text file line by line and with the information extracted from the file, it should generate an output file in required format.
(MySource.txt)
My source file will be in the following format:
Parent1|Child1|Alias1
Parent2|Child2|Alias2
Parent3|Child3|Alias3The batch should read the above file line by line, and create and output file which has the following format: (OutputFile.txt)
Delete Member
Properties(ApplicationName, DimensionName, ParentName, MemberName, RemoveChildren)
Values('Comma','C_Account','Parent1','Child1','false');Delete Member
Properties(ApplicationName, DimensionName, ParentName, MemberName, RemoveChildren)
Values('Comma','C_Account','Parent2','Child2','false');Delete Member
Properties(ApplicationName, DimensionName, ParentName, MemberName, RemoveChildren)
Values('Comma','C_Account','Parent3','Child3','false');NOTE: The number of lines in the source file is generated by another process, and does not remain constant all the time.
The output file should be over written everytime, based on the number of lines in the source file.
Anyhelp will be highly appreciated!.. :)
Thanks and Regards
Anusha
I'm not much of a genuis in batch scripting, but i can give you the logic in shell scripting. I don't think it'll be too hard for you to convert it to batch scripting Here is the code
#!/bin/sh
lineno=$(wc -l < Mysource.txt) #count no of lines in source file
a=0
while [ $a -lt $lineno ]
do
rm outputFile.txt
unset Parent child alias
read Parent child alias
echo -e "$Parent \t $child \t $alias" >> outputFile.txt # write to output file
a=`expr $a + 1`
done
You'll have to edit the output part to suit your needs as I'm not clear about what kind of text you want in the output file.
This script just reads it line by line and writes it to the output file.You can use this same logic for your scriptIf you need any help converting shell script to batch script, refer the following link
http://tldp.org/LDP/abs/html/dosbat...
Hope my answer is heplful.
| « Delete file based on inpu... | Batch Programming Help - ... » |