-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBulkProcess.bat
58 lines (53 loc) · 2.18 KB
/
BulkProcess.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@echo off
echo.
echo Converts google my maps into OSMAnd GPX files.
echo.
echo Reads in a supplied file containing a google map name and it's corresponding ID value (mid=xxxx)
echo The google map name doesn't have to be the actual name it's the string you want used for the folder.
echo.
setlocal EnableDelayedExpansion
set KMLtoGPX_PROGRAM="U:\Projects\Computer Projects\PC Software\KMLtoOSMAndGPXTracks\KMLtoOSMAndGPXTracks.py"
set MAPtoKML_PROGRAM="U:\Projects\Computer Projects\PC Software\GetGoogleMapKML\GetGoogleMapKML.py"
:getinput
set /p infile= "Enter filename containing one comma separated pair of values for each line (<name>,<mapID>): "
if exist %infile% goto execute
echo.
echo ***Missing input file: %infile% ***
echo.
goto end
:execute
:: Get the current date in YYYY-MM-DD format
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "CurrentDate=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%"
echo Current date: %CurrentDate%
set /a count=0
set /a errorCount=0
:: Read the file containing infile and outfile names
:: Lots of batch file crap having to do with file names with spaces
:: and how they are quoted. On input from cmd line use double quotes
:: around paths that have spaces. Single quotes won't work. Here in the batch
:: file I found a reference that said use single quotes and type command
:: to get around these issues.
:: Tokens split on comma, first token put in %%A and second in %%B
for /f "eol=# tokens=1,2 delims=," %%A in ('type %infile%') do (
:: Execute the batch file with infile, outfile, and current date as arguments
set /a count+=1
set "outputfolder=%%A-%CurrentDate%"
set "kmlfile=!outputfolder!.kml"
echo =========================================================================================
echo Processing map #!count! %%A
::echo count: !count! A: %%A outputfolder: !outputfolder! mapid: %%B kmlfile: !kmlfile!
py %MAPtoKML_PROGRAM% %%B "!kmlfile!"
if !ERRORLEVEL! EQU 0 (
py %KMLtoGPX_PROGRAM% "!kmlfile!" -w 12
if !ERRORLEVEL! EQU 0 (
echo Delete file !kmlfile!
del "!kmlfile!"
) else (set /a errorCount+=1)
) else (set /a errorCount+=1)
echo.
)
echo Processed %count% maps. Error count: %errorCount%
:end
endlocal
pause