Rem // Prepare an empty file to begin with:įor /F "delims=" %%I in ('dir /B /A:D-L-H-S /O:N "?"') do (Ĭopy /B "metadata.txt" "%%I\gpsdata.txt" "metadata.txt" > nulįor those that may need to convert using GPSBabel on several txt files with the same name inside different subfolders to get a GPX out of them, I was able to perform this with the following batch file: setlocal enabledelayedexpansionįOR /F "delims=" %%i IN ('DIR /S /B C:\FOLDER1\metadata.txt') DO "X:\GPSBabel\gpsbabel.exe" -t -i xcsv,style=C:\mystyle.style -f "%%i" -x discard,hdop=10,vdop=20 -x duplicate,location -x simplify,crosstrack,error=0.001k -o gpx -F "%%i".gpxįor /F "delims=" %%f IN ('DIR /S /B C:\FOLDER1\*.gpx') DO set f=!f! -f "%%f" Rem // Append the text file to the result file:Ĭopy /B "C:\FOLDER1\metadata.txt" "%%~I\gpsdata.txt" "C:\FOLDER1\metadata.txt" > nulĪpproach using for /F and dir (sub-directories are sorted in alphabetic manner due to /O:N): rem // Change into target directory: Rem // Check whether the current sub-directory contains the text file: Rem // Iterate over the immediate sub-directories:įor /D %%I in ("C:\FOLDER1\?") do ( What you need is for /D, or for /F together with dir in order to control sorting.Īpproach using for /D (sub-directories are iterated in the order as returned by the file system): rem // Prepare an empty file to begin with: ![]() ![]() Do not use for /R, neither do use for /F with dir /S, since you have got a flat directory structure.
0 Comments
Leave a Reply. |