|
@@ -10,59 +10,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
function ts() {
|
|
|
return $(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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-echo "Source [$(pwd)]:"
|
|
|
-read src
|
|
|
-if [ ${src} != "" ]l then
|
|
|
- src = "$(pwd)"
|
|
|
+if [ -z ${src} ]; then
|
|
|
+ read -p "Source [$(pwd)]: " src
|
|
|
+ if [ -z ${src} ]; then
|
|
|
+ src="$(pwd)"
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
|
|
|
-echo "Destination [$(pwd)]:"
|
|
|
-read dst
|
|
|
-if [ ${dst} != "" ]l then
|
|
|
- dst = "$(pwd)"
|
|
|
+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} -eq ${dst} ]; then
|
|
|
- echo "[$ts] Source and destination are the same, exiting..."
|
|
|
+if [ ${src} = ${dst} ]; then
|
|
|
+ echo "Source and destination are the same, exiting..."
|
|
|
exit 2
|
|
|
fi
|
|
|
|
|
|
-
|
|
|
-echo "Description of session/event:"
|
|
|
-read desc
|
|
|
-if [ ${desc} != "" ]l then
|
|
|
-
|
|
|
- desc = " - ${desc}"
|
|
|
-fi
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- dst_subdir="${dst}/${file_creation_date}${desc}"
|
|
|
-
|
|
|
- file_new_name="$(read creation date and time, format)-${file}"
|
|
|
-
|
|
|
- echo "[ $(ts()) ] src: [${src}/${file], dst: [${dst_subdir}/${file_new_name}]"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mv -v ${src}/${file} ${dst_subdir}/${file_new_name}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+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
|
|
|
+
|
|
|
+ find ${dst} -
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ dst_subdir="${dst}/${file_creation_date}${note}"
|
|
|
+
|
|
|
+ file_new_name="$(read creation date and time, format)-${file}"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+else
|
|
|
+
|
|
|
+ echo "Operation is not confirmed."
|
|
|
+ exit 1
|
|
|
+fi
|