- Photo Gallery
- Chicagoland Good & Cheap Restaurants
- Chicagoland Filipino Food Sources
- Coffee shops near Chicago 'El' Stations
- My salad foodhack
- OmniCode
- Backing up photographs: my way
- Badminton photography: my way...
- How I manage my social life…
- Monte Carlo Simulations for Retirement planning (in Perl)
- What D&D Character Am I?
- Skype Settings with Ubuntu 8.10 Intrepid Ibex
- Laser pointer sniper game
- CTA Text Tracker
- Establishing a Low-cost Web Presence
- Homebrew bike lights
- How to enable remote XWindows on Portable Ubuntu
- Combining mod_security and phpMyAdmin for Ubuntu
- Perl Metromix scraper
- Script to copy Podcast files to USB drive
- Updating ipfilter.dat using wget
- Personal Finance 1
- Personal Finance 2
- Beer I've Tasted
- Sports Selection via Pondex
- My Public Key
- Contact us
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
- Wordpress category:
