-
Notifications
You must be signed in to change notification settings - Fork 2
/
apk_rename.sh
executable file
·29 lines (25 loc) · 881 Bytes
/
apk_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
#!/bin/bash
rename() {
local manifest=$(tools/./aapt d badging "$1")
local label=$(echo $manifest | grep -Po "(?<=application: label=')(.+?)(?=')")
local package_name=$(echo $manifest | grep -Po "(?<=package: name=')(.+?)(?=')")
local version_code=$(echo $manifest | grep -Po "(?<=versionCode=')(.+?)(?=')")
local version_name=$(echo $manifest | grep -Po "(?<=versionName=')(.+?)(?=')")
local apk_name="$label - $version_name - $version_code - $package_name.apk"
local final_name=$(echo $apk_name | tr -d '\\' | tr -d '/')
#if [ "$apk_name" == " - - - .apk" ]; then
# echo "🚫 $1 : faild to rename this file"
# return
#fi
echo
mv -f "$1" "renamed/$final_name"
echo "✅ Old name: $1 👇"
echo "✅ New name: $final_name"
echo
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
echo
}
for apk in input/*.apk
do
rename "$apk"
done