#!/usr/bin/bash
# File:fix-fat-dst-modtimes-plug.sh
#--------------------------------------------------------
# Run fix-fat-dst-modtimes.py on Android to adjust file
# modification times on your FAT32 $plug copy up or down 
# by an hour, to make them in synch with non-FAT32 drive 
# times after a daylight-savings-time (DST) rollover.
# Example: "bash <thisfile>.sh -add 1 <logfilename>?".
# This uses path variables set in your ~/.bash_profile.
# See _README.html for all general usage instructions.
#--------------------------------------------------------

# Load current path settings
source ~/.bash_profile

# Run in work folder for logs
pushd $work > /dev/null
echo "Starting: $PWD"

# Route logfile output here
logdir=Admin-Mergeall

# Filename passed as arg else generated
if [ $# == 3 ]
then
    logname=$3
else
    logname=fix-fat-dst-modtimes-$(date +%Y%m%d-%H%M%S).txt
fi

# Create logfiles dir if needed
if [ ! -e $logdir ] 
then
    mkdir $logdir
    echo "Created $logdir"
fi

# Run and save log: requires [(-add | -sub) N] on command line
python Mergeall-source/fix-fat-dst-modtimes.py \
    $plug \
    $1 $2 \
        > $logdir/$logname

# Back to starting dir
popd > /dev/null
echo "Finished: $PWD"
