forked from chris-barry/bin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync-clip.sh
executable file
·34 lines (28 loc) · 1.03 KB
/
sync-clip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
# Used for syncing my music with my music player.
# $MUSIC : the directory where you keep symlinks to your music
# $DRIVE : the mount point of your music player
# $FOLDER : where your music is located on the music player
# $IGNORE : files types you don't wish to copy, e.g. album art, .Trashes, ...
MUSIC=$HOME/Documents/clip-music/
DRIVE=/media/clip
FOLDER=Music/
RSYNCFLAGS="--recursive --delete-before --copy-links -P"
# TODO Ignore dumb files (image files, hidden files...)
IGNORE="*.jpg *.JPG *.m3u *.log"
if [ ! -z "`mount | grep $DRIVE`" ]; then
# Check if there's enough room on the drive
CLIP_SIZE=`df $DRIVE | tail -n1 | awk '{print $4}'`
MUSIC_SIZE=`du -sHc $MUSIC/* | tail -n 1 | awk '{print $1}'`
if [ $MUSIC_SIZE -gt $CLIP_SIZE ]; then
echo "Not enough room on the clip for this directory!"
exit 1
fi
echo "Starting copy..."
echo rsync $RSYNCFLAGS $MUSIC "$DRIVE/$FOLDER"
sudo rsync $RSYNCFLAGS $MUSIC "$DRIVE/$FOLDER"
echo "Finished copy, remember to eject!"
else
echo "No drive mounted."
fi
exit 0