Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.
"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
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.0000I would like to have the x and y coordinates taken from a NMEA line.
Here is my Batch to create the world files:
@echo offfor /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
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
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
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
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 forthSorry for not being clear enough.
Report Offensive Follow Up For Removal
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
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 offfor /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
'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
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
![]() |
![]() |
![]() |

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