--- /dev/null
+#!/bin/bash
+# DESCRIPTION:
+# Wrapper script around make_home_videos.pl script that
+# facilitates copying over the daily_clips to another
+# linux server location, properly merging the clips
+# created with the existing clips and playlists on
+# the remote server.
+# USAGE: make_home_videos.cmd <tapename>
+# EXAMPLE: make_home_videos.cmd Dec06-Apr07
+
+SERVER="/naspool/videos/HomeVideos"
+MAKE_VIDEOS="/naspool/videos/bin/make_home_videos.pl"
+
+$MAKE_VIDEOS -e -m -p -a -n $*
+
+# Copy the daily clips over to the main file server
+pushd "$*/daily_clips" > /dev/null
+lastyear=""
+for i in `/bin/ls -1 *.avi`;
+do
+ filename=`echo "$i" | sed 's/.avi//g'`
+ year=`echo "$filename" | awk --field-separator - '{print $1}'`
+ month=`echo "$filename" | awk --field-separator - '{print $2}'`
+ day=`echo "$filename" | awk --field-separator - '{print $3}'`
+
+ # set lastyear if we haven't done so yet
+ if [[ -z "$lastyear" ]];
+ then
+ lastyear="$year"
+ fi
+
+ # if we have changed year directories, remake the playlists for lastyear
+ if [[ "$year" != "$lastyear" ]];
+ then
+ pushd "$SERVER/$lastyear" > /dev/null
+ $MAKE_VIDEOS -p -d .
+ popd > /dev/null
+ fi
+
+ # make the destination directory if it is missing
+ if [[ ! -d "$SERVER/$year" ]];
+ then
+ mkdir "$SERVER/$year"
+ fi
+
+ # don't overwrite existing filenames
+ basefilename="$filename"
+ num=0
+ while [[ -f "$SERVER/$year/$filename.avi" ]];
+ do
+ ((num++))
+ filename="$basefilename.$num"
+ done
+
+ echo "Copying $i to $SERVER/$year/$filename.avi"
+ cp "$i" "$SERVER/$year/$filename.avi"
+
+ lastyear=$year
+done
+
+# remake the playlists for year
+pushd "$SERVER/$year" > /dev/null
+$MAKE_VIDEOS -p -d .
+popd > /dev/null
+
+popd > /dev/null
+