-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTEXT
executable file
·153 lines (126 loc) · 2.88 KB
/
TEXT
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
#date 20180709
#Funtion make a new job folder.
# Color
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
job=$1
test_input(){
read -p "Please enter job code, digits only:" job
test -z "$job" && echo "You didn't input anything." && test_input
input_length=${#job}
[ $input_length -lt 6 ] && echo -e "Less than ${red}6 digits${plain}, illegal input." && test_input
}
connection_detect(){
cd /Volumes/datavolumn_bmkserver_Pub/ 2> /dev/null
if ! [ $(pwd) == "/Volumes/datavolumn_bmkserver_Pub" ]; then
echo -e "${red}Sorry, can't connect to server, please ensure it was connected! ${plain}"
exit 0
fi
}
draft_folder(){
path1="/Volumes/datavolumn_bmkserver_Pub/新做稿/未开始/"
path2="/Volumes/datavolumn_bmkserver_Pub/新做稿/进行中/"
cd ${path1}?${job}* 2> /dev/null
p1=$?
cd ${path2}?${job}* 2> /dev/null
p2=$?
if [ $p1 == 0 ]; then
cd ${path1}?${job}*
pwd
test -e *.xls && cp *.xls ~/Desktop/a.xls
test -e *.xlsx && cp *.xlsx ~/Desktop/a.xlsx
elif [ $p2 == 0 ]; then
cd ${path2}?${job}*
pwd
test -e *.xls && cp *.xls ~/Desktop/a.xls
test -e *.xlsx && cp *.xlsx ~/Desktop/a.xlsx
else
echo -e "${red}Can't locate the files on draft folder.${plain}"
fi
}
cat_txt(){
OLDIFS=$IFS
IFS=$'\n'
> ~/Desktop/a.txt
for f in $(ls -1 *.txt)
do
cat $f >> ~/Desktop/a.txt
echo -en '\n\n' >> ~/Desktop/a.txt
done
IFS=$OLDIFS
}
get_txt(){
[ -e *.txt ] 2> /dev/null
result_t=$?
if [ $result_t == 0 ]; then
cat *.txt > ~/Desktop/a.txt
echo -en '\n\n' >> ~/Desktop/a.txt
elif [ $result_t == 1 ]; then
echo "One PDF file only"
echo "$(ls -1 *.pdf)" 1> ~/Desktop/a.txt
echo -en '\n\n' >> ~/Desktop/a.txt
else
cat_txt
fi
}
pub_today(){
month=`date +%Y%m`
today=`date +%m%d`
yesterday=`date -v-1d +%m%d`
pathtoday="/Volumes/datavolumn_bmkserver_Pub/${month}/${today}/"
pathyesterday="/Volumes/datavolumn_bmkserver_Pub/${month}/${yesterday}/"
cd ${pathtoday}?${job}* 2> /dev/null
p1=$?
cd ${pathyesterday}?${job}* 2> /dev/null
p2=$?
if [ $p1 == 0 ]; then
cd ${pathtoday}?${job}*
pwd && current_folder_path=$(pwd)
get_txt
elif [ $p2 == 0 ]; then
cd ${pathyesterday}?${job}*
pwd && current_folder_path=$(pwd)
get_txt
else
echo -e "${red}Can't locate the folder on today and yesterday.${plain}"
fi
}
func_select(){
clear
draft_folder
pub_today
}
open_folder(){
open "$current_folder_path"
}
drat_text(){
read -p "'Y' to process draft artwork texts and other to stop:" option
case $option in
'y' | 'Y')
draft_select
open_folder
;;
*)
end_pattern
exit 0
;;
esac
}
end_pattern(){
printf "\
______ __ __ __ __\r\n\
/ ____/___ ____ ____/ / / /_ _______/ /__ / /\r\n\
/ / __/ __ \/ __ \/ __ / / / / / / ___/ //_/ / / \r\n\
/ /_/ / /_/ / /_/ / /_/ / / / /_/ / /__/ ,< /_/ \r\n\
\____/\____/\____/\__,_/ /_/\__,_/\___/_/|_| (_) \r\n\
"
}
connection_detect
test -z $job && test_input
func_select
drat_text
end_pattern
exit 0