Script to copy Podcast files to USB drive

Comments/Improvements are welcome...

- The script won't work if the file HAS a space in the filename (I'll leave it up to the user as an exercise to add this routine)
- I placed this script in my crontab to download the various podcasts/vidcasts I listen to/watch.
- The script will copy starting from the largest files to the smallest files (if space is available.) That'll minimize the available space on the USB drive
- Remember to delete the podcasts/vidcast files on the destination drive after you are finished listening/watching them. New files will added when free space is available.

#!/bin/bash
if [ -s /targetdirectory ]; then
# copy files from podcast to USB
echo "USB Drive present..."
# removes spaces in the file name
cd /sourcedirectory
for file in `ls -Ss1 | grep -v total | awk '{print $2}'` ; do
# check for available space
freespace=$(df --sync --block-size=1 /targetdirectory | grep -v Use |  awk '{print $4}')
#echo $freespace
# check size of file to be moved
filesize=$(du -b "$file" | cut -f 1)
#echo $filesize
if [ $filesize -lt $freespace ]; then
#copy file
echo "Copying files... Please wait..."
rsync -avtzr --remove-source-files /sourcedirectory/"$file" /targetdirectory ;
fi
done
else
echo "Please plug in the USB drive..."
exit 0
fi