hi all,
made a script and thought i would show you guys about it,
Code:
#!/bin/bash
echo "is this archive for an audio tar (press 1) or an audio directory (press 2)"
read method
case $method in
1)
echo "please specify full path to tar file"
read -e tar
base=$(basename "$tar")
echo "please enter ID number ie ID1234"
read id
echo "please specify where you want the tar file to be stored"
read -e dest
if ! mv "$tar" "$id"_"$base" ; then
echo "something went wrong with the mv command, please do manually"
exit
fi
if ! rsync -avh "$id"_"$base" "$dest" ; then
echo "something went wrong with the rsync command, please do manually"
exit
fi
if ! rm -f "$id"_"$base" ; then
echo "something went wrong with the rm -f command, please do manually"
exit
fi
;;
2)
echo "please specify full path to directory you want to be made into a tar"
read -e dir
cd $dir
cd ..
base=$(basename "$dir")
echo "please enter ID number ie ID1234"
read id
echo "please specify where you want the tar file to be stored"
read -e dest
if ! tar -cf "$id"_"$base".tar "$base" ; then
echo "something went wrong with the tar, please do manually"
exit
fi
if ! rsync -avh "$id"_"$base".tar "$dest" ; then
echo "something went wrong with the rsync, please do manually"
exit
fi
if ! rm -f "$id"_"$base".tar ; then
echo "something went wrong with the rm -f command, please do manually"
exit
fi
if ! rm -rf "$dir" ; then
echo "something went wrong with the rm -rf command, please do manually"
exit
fi
;;
*)
echo "invalid selection, please re-run the script"
exit
;;
esac