-
Notifications
You must be signed in to change notification settings - Fork 0
/
moveCSV.sh
90 lines (76 loc) · 1.81 KB
/
moveCSV.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
#
#-- Version: 1.0
#-- Author: Enrico Spinielli
#-- Date: 2023/07/14
#-- Last update: 2023/07/14
#-- Copyright (C) 2016 Eurocontrol/PRU
##- Usage: moveCSV
##- Move all AIU download CSV files (*.csv.bz2 in current directory)
##- to the Drive folder for portal publication
##-
##- Options:
##- -h, --help Print a usage message summarizing the command-line options, then exit.
##- -V, --version Output version information and exit.
##-
##- Examples:
##- $ moveCSV
##-
##- Caveat: be sure to use gnu-getopt and not OSX builtin or Git Bash missing one ;-)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT="$(basename "${BASH_SOURCE[0]}")"
help=$(grep "^##-" "${SCRIPT_DIR}/${SCRIPT}" | cut -c 4-)
version=$(grep "^#--" "${SCRIPT_DIR}/${SCRIPT}" | cut -c 4-)
opt_h() {
echo "$help"
}
opt_v() {
echo "$version"
}
# Execute getopt
TEMP=$(getopt -o :hV --long "help,version" -n "${SCRIPT}" -- "$@");
if [ $? != 0 ]
then
echo "Invalid option(s): $*" >&2
exit 1
fi
eval set -- "$TEMP"
unset TEMP
while true; do
case $1 in
-h|--help)
opt_h
exit
;;
-V|--version)
opt_v
exit
;;
--)
shift
break
;;
\?)
echo "Invalid option: -$OPTARG" >&2
opt_h
exit 1
;;
*)
echo "Internal error!"
exit 1
;;
esac
done
# there are NO mandatory arguments
if (( $# != 0 )); then
echo "Error: illegal number of parameters"
opt_h
exit 1
fi
(
cd "${SCRIPT_DIR}/" || exit;
echo "Moving *.csv.bz2 ..."
# TODO: remove hardcoded path
mv *.csv.bz2 'C:\Users\spi\OneDrive - EUROCONTROL\Download data files\csv'
echo "Moving *.csv.bz2 ... done."
)