-
Notifications
You must be signed in to change notification settings - Fork 3
/
bash_rename.sh
executable file
·210 lines (158 loc) · 5.52 KB
/
bash_rename.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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/bash
# batch processing svg filenames
# from Noto Emoji source
# (https://github.com/googlei18n/noto-emoj)
# to match https://github.com/eosrei/twemoji-color-font
# Run this to convert SVG filenames from Google's repository
# to be compatible with eosrei's.
# (Don't run this twice on the same SVGs,
# Or it will actually mess up their names.) 😕
# This file may break if Google decides
# to rename their SVGs. Oh well. 🤷
# Note: Here is an example SVG filename from Google:
# "emoji_u00a9.svg"
# Here is an example ZWJ sequence SVG filename from Google:
# "emoji_u1f469_1f3fd_200d_1f692.svg"
# We want to turn those into something like this:
# "00a9.svg" and "1f469-1f3fe-200d-1f692.svg"
# because we are borrowing eosrei's build process...
# And eosrei's build process is designed with
# these filenames in mind.
# There are lots of comments in this file, 💬
# and you're encouraged to read them
# if you'd like to modify it.
# (Grabbing the filename of every SVG in this directory
# that begins with "emoji")
for i in $(\ls -d emoji*.svg)
do
# We are removing the beginning of every filename,
# i.e. we are removing "emoji_u" ✂
# So we must trim the first 6 characters.
j=${i:7}
# Storing the value of manipulated string in $j, so we can
# use it in a mv and then reuse it in an echo, without having to
# re-calculate the new string twice. It is faster this way. ⚡
mv $i $j
echo "renaming from $i to $j"
done
# see: http://tldp.org/LDP/abs/html/string-manipulation.html 📖
# subheading "Substring Extraction"
# (Grabbing the name of every SVG in this directory
# that contains an underscore in the filename)
for i in $(\ls -d *_*.svg)
do
j=${i//_/-}
mv $i $j
echo "renaming from $i to $j"
# remove underscores, replace with dashes.
# See: http://www.thegeekstuff.com/2010/07/bash-string-manipulation/ 📖
# "Replace all the matches" heading
done
# (Grabbing the name of every SVG in this directory
# that contains -2640 in the filename)
for i in $(\ls -d *-2640*.svg)
do
j=${i//-2640/-2640-fe0f}
mv $i $j
echo "renaming from $i to $j"
# remove "-2640", replace with "-2640-fe0f".
# 2640 is "Female Sign" ♀️
# https://codepoints.net/U+2640
# fe0f is "Variation Selector 16".
# https://codepoints.net/U+FE0F 🌐🖱
done
# (Grabbing the name of every SVG in this directory
# that contains -2642 in the filename)
for i in $(\ls -d *-2642*.svg)
do
j=${i//-2642/-2642-fe0f}
mv $i $j
echo "renaming from $i to $j"
# remove "-2642", replace with "-2642-fe0f".
# 2642 is "Male Sign" ♂️
# https://codepoints.net/U+2642
done
# (Grabbing the name of every SVG in this directory
# that contains 1f3cc-200d in the filename)
for i in $(\ls -d *1f3cc-200d*.svg)
do
j=${i//1f3cc-200d/1f3cc-fe0f-200d}
mv $i $j
echo "renaming from $i to $j"
# remove "1f3cc-200d", replace with "1f3cc-fe0f-200d".
# 1f3cc is "Golfer" 🏌️
# https://codepoints.net/U+1f3cc
# 200d is "Zero Width Joiner"
# https://codepoints.net/U+200d 🌐🖱
done
# (Grabbing the name of every SVG in this directory
# that contains 1f3f3-200d in the filename)
##### for i in $(\ls -d *1f3f3-200d*.svg)
##### do
##### j=${i//1f3f3-200d/1f3f3-fe0f-200d}
##### mv $i $j
##### echo "renaming from $i to $j"
# remove "1f3f3-200d", replace with "1f3f3-fe0f-200d".
# 1f3f3 is "Waving White Flag" 🏳️
# https://codepoints.net/U+1f3f3
# Not yet implemented on the Noto SVG side, this is for the Rainbow Flag sequence. 🏳️🌈 🏳️🌈 🏳️🌈
# Leaving this here in the hopes Google will release this SVG.
##### done
# (Grabbing the name of every SVG in this directory
# that contains -2695 in the filename)
for i in $(\ls -d *-2695*.svg)
do
j=${i//-2695/-2695-fe0f}
mv $i $j
echo "renaming from $i to $j"
# remove "-2695", replace with "-2695-fe0f".
# 2695 is "Staff of Aesculapius" ⚕️
# https://codepoints.net/U+2695
done
# (Grabbing the name of every SVG in this directory
# that contains -2696 in the filename)
for i in $(\ls -d *-2696*.svg)
do
j=${i//-2696/-2696-fe0f}
mv $i $j
echo "renaming from $i to $j"
# remove "-2696", replace with "-2696-fe0f".
# 2696 is "Scales" ⚖️
# https://codepoints.net/U+2696
done
# (Grabbing the name of every SVG in this directory
# that contains -2708 in the filename)
for i in $(\ls -d *-2708*.svg)
do
j=${i//-2708/-2708-fe0f}
mv $i $j
echo "renaming from $i to $j"
# remove "-2708", replace with "-2708-fe0f".
# 2708 is "Airplane" ✈️
# https://codepoints.net/U+2708
done
##### The following one ("Heavy Black Heart")
##### Shouldn't be needed. It might actually
##### break things at the moment. Uncomment if needed.
# (Grabbing the name of every SVG in this directory
# that contains -2764 in the filename)
##### for i in $(\ls -d *-2764*.svg)
##### do
##### j= ${i//-2764/-2764-fe0f}
##### mv $i $j
##### echo "renaming from $i to $j"
# remove "-2764", replace with "-2764-fe0f".
# 2764 is "Heavy Black Heart" ❤️
# https://codepoints.net/U+2764
##### done
##### mv 1f3f4-200d-2620.svg 1f3f4-200d-2620-fe0f.svg
##### echo "renaming from 1f3f4-200d-2620.svg to 1f3f4-200d-2620-fe0f.svg (yarrr!)"
# rename "1f3f4-200d-2620.svg" to "1f3f4-200d-2620-fe0f.svg".
# 1f3f4 is "Waving Black Flag" 🏴
# https://codepoints.net/U+if3f4
# 2620 is "Skull and Crossbones" ☠️
# https://codepoints.net/U+2620
# Not yet implemented on the Noto SVG side, this is for the Pirate Flag sequence.
# Pirate Flag is a non-standard Twitter Emoji sequence. http://emojipedia.org/pirate-flag/ 😃📖
# It is unlikely to be implemented in Noto Emoji, but you never know.
# https://www.youtube.com/watch?v=i8ju_10NkGY 🏴☠️ 🏴☠️ 🏴☠️