#!/bin/sh # Takes a list of files and u/l them to a server via scp. Also creates # a new message in Mail.app with the urls to the u/led files and a subject # line remniscent of the "Mail" button in iPhoto. progname=maillink # parameters used to access the server server=example.com user=username url="http://www.$server/" path="www" # check for at least one arg if [ $# -eq 0 ]; then echo "Usage: $progname file [file ...]" 1>&2 exit 1 fi # these are the mime-types that we create particular subject lines for video="" audio="" image="" other="" # clear the name of the file and the body of he mail message name='' #text='The file(s) are uploading, write your message here.' text='' # generate the body of the mail message for file; do # verify that a file size=`/bin/ls -ld "$file" | /usr/bin/awk '/^-/{print $5}'` if [ "x$size" = "x" ]; then echo "$progname: not a regular file: $file" 1>&2 exit 2 fi # get the type type=`/usr/bin/file -ib "$file"` case "$type" in video/*) video=iMovies ;; audio/*) audio=iTunes ;; image/*) image=iPhotos ;; *) other=files ;; esac # add to the body of the mail message name=`/usr/bin/basename "$file"` text="$text $size bytes: $url$name" done # if there is only one link, the name is the subject if [ $# -eq 1 ]; then subject="$name" else # figure-out a consistent subject type="$video$audio$image$other" case "$type" in iMovies | iTunes | iPhotos | files) ;; *) type=files ;; esac subject="$# great $type" fi # switch to Mail.app and open the new message /usr/bin/osascript <