Computing.Net > Forums > Programming > Read .txt data with Batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

Read .txt data with Batch

Reply to Message Icon

Name: GooRoo
Date: October 29, 2008 at 14:03:57 Pacific
OS: XP
CPU/Ram: Intel 2Gig
Manufacturer/Model: Dell
Comment:

How do I make a batch file to read a lines in a .txt file, and write that file in another batch program. I have NMEA code from GPS unit and here is an example.

$GPGGA,161229.487,3723.2475,N,12158.3416,W,1,07,1.0,9.0,M,,,,0000*18

The [ 3723.2475,N,12158.3416,W ] is the latitude and longitude locations.


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: October 29, 2008 at 14:25:51 Pacific
Reply:

"read a lines"

Not clear what's needed.

You want a bat to create another bat? Based on what?


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 2
Name: GooRoo
Date: October 29, 2008 at 14:37:45 Pacific
Reply:

Ah sorry, I had alot of stuff going on when I typed that. Anyways I have a .bat file that will create a .jpw file which is a .jpg world file. A world file is a txt file with 6 lines that give a mapping application direction where to place a jpg image spatially.

World Files look like this;

Line 1: pixel size in the x-direction in map units/pixel

Line 2: rotation about y-axis

Line 3: rotation about x-axis

Line 4: pixel size in the y-direction in map units, almost always negative[3]

Line 5: x-coordinate of upper left pixel

Line 6: y-coordinate of the upper left pixel

i.e

1.0000
0.0000
0.0000
-1.0000
42.0000
70.0000

I would like to have the x and y coordinates taken from a NMEA line.


Here is my Batch to create the world files:


@echo off

for /f "tokens=* delims= " %%A in ('dir *.jpg /b') do (
echo 0.000029528140317>> %%~nA.jgw
echo 0.000000000000000>> %%~nA.jgw
echo 0.000000000000000>> %%~nA.jgw
echo -0.000029528140317>> %%~nA.jgw
echo 42.000000000000000>> %%~nA.jgw
echo 70.000000000000000>> %%~nA.jgw
)

Any thoughts?

Thanks



Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: October 29, 2008 at 15:12:30 Pacific
Reply:

It looks like your bat will create a jpw for each jpg. But I'm missing the question or problem.


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 4
Name: GooRoo
Date: October 29, 2008 at 15:39:13 Pacific
Reply:

Yup that program does create a jgw file for every jgp. What I would like to do is have the Latitude and Longitude numbers be retrieved from a different txt file that contains the NMEA strings.


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: October 29, 2008 at 16:32:10 Pacific
Reply:

Retrieve the same lat & long for each jpw?


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Related Posts

See More



Response Number 6
Name: GooRoo
Date: October 29, 2008 at 16:48:16 Pacific
Reply:

Nope, each .jgw is going to have a different Lat and long. The lat and long values ill come from a different text file, lets call it GPS.txt. Each line in the GPS.txt will have a different set of lat and long.

ie

42.578, 70.321
42.581, 70.438
42.765, 70.474
so on and so forth

Sorry for not being clear enough.


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: October 29, 2008 at 18:03:39 Pacific
Reply:

You need to give this more thought and get clear on what's to be done.

You've got lat/long pairs in GPS.txt; which pair goes in which jpw?


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 8
Name: GooRoo
Date: October 29, 2008 at 18:40:12 Pacific
Reply:

Sorry, Its hard to explain to someone not in the industry. OK...let me start over and maybe I can make it clearer.


Lets say I have 500 aerial images in .jpg format.

In order to geo-reference these images I needed to make a jpeg world file. (.jgw)

This file tells the mapping application where to place this image in geo-graphical space.

The file I made to make these .jgw files is below;

===============
@echo off

for /f "tokens=* delims= " %%A in ('dir *.jpg /b') do (
echo 0.000029528140317>> %%~nA.jgw
echo 0.000000000000000>> %%~nA.jgw
echo 0.000000000000000>> %%~nA.jgw
echo -0.000029528140317>> %%~nA.jgw
echo 42.000000000000000>> %%~nA.jgw
echo 70.000000000000000>> %%~nA.jgw
)
===============

The last two numbers in the file above are the latitude and longitude. Unfortunately these numbers are the same throughout every image.

To solve this problem I would like to have a different set of coordinates for each image.

*The GPS data is recorded in NMEA sentences the coordinates are included in a string.*

I can extract the coordinates in excel and make a .csv or a .txt file so the coordinates are the only thing in a line. Example below:

======
42.63521 70.63222
42.63623 70.73223
42.74212 70.82317

======


Now to combine the two!!!

I would like line 1 in the GPS coordinates file to be for the coordinates in the first jgw, the 2nd line for the 2nd jgw.......so on and so forth, up to as many points and images as I have


I think I have explained it a bit better....

I hope. Thanks for your patience.


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: October 29, 2008 at 22:41:15 Pacific
Reply:

'dir *.jpg /b'

That will list the files in no particular order. So,

'I would like line 1 in the GPS coordinates file to be for the coordinates in the first jgw, the 2nd line for the 2nd'

As defined by what?


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 10
Name: GooRoo
Date: October 30, 2008 at 04:42:24 Pacific
Reply:

Hmmmm, I didnt know that that 'dir *.jpg /b' defined them in no particular order.

I would like to have them defined based on time, because thats how GPS signals are received.

I wonder if my renaming program is messed up too? But one thing at a time.


Report Offensive Follow Up For Removal
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Read .txt data with Batch

Delete blank lines with batch file? www.computing.net/answers/programming/delete-blank-lines-with-batch-file/13018.html

editing text file with batch file www.computing.net/answers/programming/editing-text-file-with-batch-file/15231.html

Simple Batch Loop www.computing.net/answers/programming/simple-batch-loop/16647.html