My thought was it would be cool to create a script that runs daily to move all "extrafanart" folders to the SSD drive. So I created the script below. The script pretty much works as is. I would love to be able to schedule it though.
Anyway, just wondering if anyone has any thoughts?
Quote:#!/bin/bash
IFS=$'\n'
# Alter variables to suit your setup
SHARES=( "My TV" "My Movies" )
SOURCE_DISKS=( 1 2 3 4 )
DEST_DISK="5"
# Top loop includes all shares
for k in "${SHARES[@]}"; do
echo Processing $k
# 2nd loop includes all source disks
for j in "${SOURCE_DISKS[@]}"; do
echo Processing "Disk"$j
# 3rd loop recursively looks through all folders in the source shares/disks
for i in `find "/mnt/disk"$j"/"$k -type d`; do
# Only process extrafanart folders
if [ ""${i: -11}"" == "extrafanart" ]; then
# recreate file structure in destination disk, if necessary
if [ -d "/mnt/disk"$DEST_DISK"/"${i:11} ]; then
echo "/mnt/disk"$DEST_DISK"/"${i:11} already exists
else
mkdir -m a=rwx -p -v "/mnt/disk"$DEST_DISK"/"${i:11}
fi
# moves all files in the extrafanart directory to the destination folder
for m in `find $i -type f`; do
mv -u -v $m "/mnt/disk"$DEST_DISK"/"${i:11}
done
# remove directory on source disk
rm -v -r $i
fi
done
done
done

Search
Help