Skip to content

Instantly share code, notes, and snippets.

@daemonza
Created October 12, 2012 11:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daemonza/3878849 to your computer and use it in GitHub Desktop.
Save daemonza/3878849 to your computer and use it in GitHub Desktop.
Script to make uploads of tcx files from garmin connect easier
#!/usr/bin/env bash
# Copy the script into the directory where all your tcx files
# are located. Run it and then upload to Stava from the upload directory.
# Coded by Werner Gillmer <werner.gillmer@gmail.com>
echo "Creating sorting directories"
nrFiles=`ls -l ./*.tcx | wc -l`
nrDirs=$(($nrFiles/24))
counter=0
while [ $counter -lt $nrDirs ]; do
let counter=counter+1
mkdir -p "./upload/$counter"
nrFiles=0
while [ $nrFiles -lt 24 ]; do
echo "Current count is $nrFiles"
fileToMove=`ls ./*.tcx | head -1`
echo "Moving ./$fileToMove to ./upload/$counter"
mv "./$fileToMove" ./upload/$counter/
let nrFiles=nrFiles+1
done
done
# Clean up of the last couple of tcx
# files into sorting dir.
oneMoreDir=$(($nrDirs+1))
mkdir ./upload/$oneMoreDir
mv ./*tcx ./upload/$oneMoreDir
echo "done!"
@holman
Copy link

holman commented Feb 17, 2013

❤️

@gmcmillan
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment