forked from roshanconnor123/gd-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdutils.sh
126 lines (116 loc) · 3.39 KB
/
gdutils.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
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
#!/usr/bin/env bash
#=============================================================
# https://github.com/roshanconnor123/gd-utils
# File Name: gdutils.sh
# Author: roshanconnor
# Description:running gdutils
# System Required: Debian/Ubuntu
#=============================================================
cecho() {
local code="\033["
case "$1" in
black | bk) color="${code}0;30m";;
red | r) color="${code}1;31m";;
green | g) color="${code}1;32m";;
yellow | y) color="${code}1;33m";;
blue | b) color="${code}1;34m";;
purple | p) color="${code}1;35m";;
cyan | c) color="${code}1;36m";;
gray | gr) color="${code}0;37m";;
*) local text="$1"
esac
[ -z "$text" ] && local text="$color$2${code}0m"
echo -e "$text"
}
# ★★★Copy from source to destination★★★
copy() {
cd ~ && cd gd-utils
cecho r "Remember to add your SAs as Viewer in source TD and as a Contributor in Destination TD"
echo "Provide Source Folder ID"
read SRC
echo "Provide Destination Folder ID"
read DST
cecho r "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo && echo "Copy mode selected"
cecho p "A.Create a New Folder with the same name in the destination"
cecho p "B.Do not create a new Folder in the destination" && echo
read -p " Choose A/B:" option
case "$option" in
A)
node --max-old-space-size=512 copy $SRC $DST -S
;;
B)
node --max-old-space-size=512 copy $SRC $DST -S -D
;;
*)
echo
cecho r "Choose the Correct Option"
;;
esac
}
# ★★★Calculate the size★★★
count() {
cd ~ && cd gd-utils
cecho r "Remember to add your SAs as Viewer (atleast) in source TD"
echo "Provide Folder ID"
read SRC
cecho r "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo && echo "Size mode selected"
cecho p "A.Normal Size Info"
cecho p "B.Create a html file with tree like pattern"
cecho p "C.Create a snap2html index" && echo
read -p "Choose A/B/C:" option
case "$option" in
A)
node count $SRC -S
;;
B)
node count $SRC -S -t tree -o /sdcard/Tree.html
echo " Check your Internal storage to find a file called Tree.html"
;;
C)
node count $SRC -S -t snap -o /sdcard/Index.html
echo "Check your Internal Storag to find a file called Index.html"
;;
*)
echo
cecho r "Choose the Correct Option"
;;
esac
}
# ★★★Dedupe The Folder★★★
dedupe() {
cd ~ && cd gd-utils
cecho r "Remember to add your SAs as Content manager (atleast) in source TD\n"
echo "Provide Folder ID\n"
read SRC
node dedupe $SRC -S
}
# ★★★Running Gdutils★★★
printf "%s by %s -English version by %s\n" "$(cecho b GD-UTILS)" "$(cecho r iwestlin)" "$(cecho c Roshanconnor)"
cecho g "1.Copy Files to your Teamdrive"
echo "➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖"
cecho g "2.Calculate Size"
echo "➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖"
cecho g "3.Remove Duplicate Files"
echo "➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖"
cecho y "4.EXIT" && echo
read -p " Choose any Number [1-4]:" option
case "$option" in
1)
copy
;;
2)
count
;;
3)
dedupe
;;
4)
exit
;;
*)
echo
cecho r "Choose Correct Number from the Options"
;;
esac