123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- function ts() {
-
- ts=$(date)
- echo $(date )
- }
- usage () {
- echo "Usage: $0 -s - source, -d destination, -n note";
- exit 1;
- }
- while getopts s:d:n: flag
- do
- case "${flag}" in
- s) src=${OPTARG};;
- d) dst=${OPTARG};;
- n) note=${OPTARG};;
- ?) usage;;
- esac
- done
- if [ -z ${src} ]; then
- read -p "Source [$(pwd)]: " src
- if [ -z ${src} ]; then
- src="$(pwd)"
- fi
- fi
- if [ -z ${dst} ]; then
- read -p "Destination [$(pwd)]: " dst
- if [ -z ${dst} ]; then
- dst="$(pwd)"
- fi
- fi
- if [ -z ${note} ]; then
- read -p "Note of session/event: " note
- if [ -z ${note} ]; then
- note=""
- else
-
- note=" - ${note}"
- fi
- fi
- if [ ${src} = ${dst} ]; then
- echo "Source and destination are the same, exiting..."
- exit 2
- fi
- echo "Source: [${src}]"
- echo "Destination: [${dst}]"
- echo "Note: [${note}]"
- read -p "Confirm (Y): " confirm
- if [ ${confirm} = "Y" ]; then
- echo "Reading source and beginning to move..."
-
- if ! [ -d ${src} ]; then
- echo "Source directory does not exist, exiting..."
- exit 2
- fi
-
- if [ -d ${dst} ]; then
- mkdir -p -m 700 ${dst}
- fi
-
-
-
-
-
-
-
- for file in ${src}/*; do
- filename="$(basename ${file})"
-
- file_mdate="$( stat -f %Sm -t %Y-%m-%d ${file} )"
-
- mkdir -p ${dst}/${file_mdate}
- echo "[ $(ts) ]: src file : [${filename}], modification date is: ${file_mdate}, size: 11.5 MB"
-
- echo "sha256sum: [$( shasum -a 256 ${file} )]"
- echo "dst dir: [${dst}/${file_mdate}]"
-
- cp ${file} ${dst}/${file_mdate}
- echo "sha256sum: [$( shasum -a 256 ${dst}/${file_mdate}/${filename} )]"
-
-
-
-
-
- done
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- else
-
- echo "Operation is not confirmed."
- exit 1
- fi
|