473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Text file parsing in batch files

watertraveller
Hi. I'm new to batch files, and relatively new to the Windows command line in general.

I'm making a batch file for the Windows XP command line. I want to examine, for each line of a text file, what the first few characters are. I want to count up how many lines started with one set of characters, how many started with another, etc. And I want to output that count into a different text file.

I know how to read in the text and output it to a new file, but I don't know how to check just the first few characters. I also don't know how to store the count in a variable in the batch file. (Do batch files even have variables? They must, right?)

Thank you for your time; I appreciate it.
Sep 17 '08 #1
4 8238
Nepomuk
3,112 Expert 2GB
Hi watertraveller! Welcome to bytes.com!

It's great to have you here!

When you post, please always keep to the Posting Guidelines and when you post code, please post it in [code] ... [/code] tags.

About your question: Yes, you can set variables in batch files. For example:
Expand|Select|Wrap|Line Numbers
  1. set countA=0
  2. set /a countA+=1
  3. echo There were %countA% a's in that text.
will return the current value of the variable countA (which is 1).

I'm not sure how to actually extract the first character from a line, but that should certainly help a bit.

Otherwise, I'll just wish you the best and hope you enjoy being part of bytes.com!

Greetings,
Nepomuk

PS.: I've started a thread in the Feedback Forum to find out, why that signature wont show up.
Sep 18 '08 #2
jg007
283 100+
one command that might help you is ' FOR ' , just type ' for /? ' to see the syntax

I don't really know if you can do exactly what you want from a batch file / dos and I have not tried to do anything similar but I suspect that you might have to resort to using VBScript to achieve this.

also a little more complicated but you might want to look at Microsoft's Powershell as it is VERY powerful once you work out how to use it :)
Sep 18 '08 #3
Thanks, I'll take a look at vbscript and, if I have to, PowerShell.
Sep 23 '08 #4
jg007
283 100+
post back if you have any problems and if I can find time I will see if I can work out some vbs code.
Sep 24 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dave S | last post by:
Hello all, Hope this is the correct group for this question. I couldn't find a vb beginners group. I am getting overwhelmed and need some help. I did this very easily in a batch file (only three...
5
by: gwarning! | last post by:
Goal: Have multiple text files, each of various lengths, be concatenated together into one final consolidated text file. Problem: Since the names of the files to be concatenated can change from...
2
by: Todd_M | last post by:
I was wondering what anyone might suggest as "best practice" patterns for streaming out fixed formatted text files with C#? Let's say we get our data in a dataset table and we need to iterate over...
4
by: ed | last post by:
Hi all, I'm very new to vb (2nd day) and I need to create a small app that will replace my old batch file with a flashy gui. I had some experience with access 2.0 which helps ;) What I would...
15
by: batman | last post by:
i have a text file that is like: date = OCT0606 asdf sdaf asdfasdgsdgh asdfsdfasdg START-OF-DATA asdfasdfg asdfgdfgsfg
0
by: Ludwig Stockmann | last post by:
Hi, everybody: I am really new to vb.net, and I need to know if there is any way to input parameters from a Textbox in a 100% vb.net form to a batch file. I have created 3 text...
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
2
by: Cliff72 | last post by:
I'm creating a database that will be uploading some text files into an access table. The problem is that the text files have a header which messes up my import specs. so what i have had to do is to...
6
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hello, I have an XML file generated from a third party application that I would like to parse. Ideally, I plan on having a windows service setup to scan various folders for XML files and parse the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.