Skip to content

Instantly share code, notes, and snippets.

@uotw
Last active November 28, 2024 20:04
Show Gist options
  • Save uotw/a1ea77b7a3f155f81c1e4ed25b8e19a5 to your computer and use it in GitHub Desktop.
Save uotw/a1ea77b7a3f155f81c1e4ed25b8e19a5 to your computer and use it in GitHub Desktop.
MacOS bash script to periodically sync two folders of FIT files
#!/usr/bin/env bash
# Check if two arguments (source and destination folders) are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <source_directory> <destination_directory>"
exit 1
fi
while true
do
# Rsync command to sync .fit files
rsync -azP --include='*.fit' --exclude='*' "$1" "$2"
# Feedback messages
echo "*************"
echo "Sleeping..."
echo "*************"
sleep 150
done
@uotw
Copy link
Author

uotw commented Nov 28, 2024

This script was written to keep a remote ASI AIR folder in sync with a local Mac folder. It checks every 2.5 minutes for changes, only moving FIT files.

Installation

  • download script to your local storage folder
  • open Terminal and change to your local folder: cd <localfolder>
  • create a mount point for your ASIAIR: mkdir ASIAIR

Usage

  • open Terminal and change to your script folder: cd <localfolder>
  • mount your ASIAIR as a network drive: mount_smbfs //[email protected]/TF%20Images/ ASIAIR/
  • run the script with ./keepsync.sh ASIAIR/<from folder>/ <to folder>/
  • to stop the script either close the Terminal window or hit Control-C to break

More details

  • example command ./keepsync.sh ASIAIR/Autorun/Light/M42/ M42/Lights/
  • Note: the trailing slashes are key here
  • Make sure your ASIAIR is connected to the same local network
  • You can browse the ASIAIR folders using Finder or using the terminal, example: ls ASIAIR/Autorun/Light/

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