Search code examples
windowsbatch-file

Merge all .gpx files within a folder into one file with GPSbabel


I want to use GPSbabel to merge all single .gpx files within one folder into one file called for example merge.gpx how can i archive something like this?

I know how to do it manually:

gpsbabel -i gpx -f "folder/of/file/1.gpx" -f "folder/of/file/2.gpx" -f "folder/of/file/3.gpx" -o gpx -F "folder/of/file/merge.gpx"

But because there are up to 20 such files within one folder i would like to use a batch (.bat) file to do this automatically? I'm nearly completely new to batch files and could not find any information how to archive that.


Solution

  • Try this:

    setlocal enabledelayedexpansion
    cd "folder/of/file"
    set f=
    for %%f in (*.gpx) do set f=!f! -f "%%f"
    gpsbabel -i gpx !f! -o gpx -F "merge.gpx"