#!/bin/bash

# this is called as an NSTask from -[Application emailLogs:] to create a directory contents summary

OUTPUT_FILE="${1}"

TARGET_DIR="${2}"

date > $OUTPUT_FILE

while [ -n "$TARGET_DIR" ]
do

	echo "" >> $OUTPUT_FILE
	echo "Contents of directory \"$TARGET_DIR\":" >> $OUTPUT_FILE
	
	ls -lha "$TARGET_DIR/"* >> $OUTPUT_FILE
	echo "" >> $OUTPUT_FILE
	
	shift
	TARGET_DIR="${2}"
	
done
