Created
April 14, 2018 23:13
-
-
Save d0nutptr/9cb9daef2eddd81610880b52c48ceadb to your computer and use it in GitHub Desktop.
This renames all of the files with a .smali extension to a more logical filename based on the .source entry in the smali file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Renames files outputed by `apktool d <apk>` to <source>.smali where <source> is the value in the .source entry of the smali file | |
| # This isn't meant to be 100% correct but it works in 99% of cases | |
| # ./apktool_name_corrector.sh ~/Documents/my_smali_output_folder | |
| shopt -s globstar | |
| start_dir=$1 | |
| for e in "${start_dir}"/**; do | |
| if [ -f "${e}" ] ; then | |
| if [ ${e: -6} == ".smali" ] ; then | |
| source=$(cat "${e}" | grep -Po "(?<=\.source\s\")[^\"]*") | |
| dir_name=$(dirname "${e}") | |
| new_name="${dir_name}/${source}.smali" | |
| mv "${e}" "${new_name}" | |
| fi | |
| fi | |
| done | |
| echo "done" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the smali output doesn't have a
.sourceline then this is going to rename the file to.smaliwhich is likely undesirable behavior. This should probably check that the name is not 0 length.