I thought this was a useful tip that people would appreciate, but I didn't think it was worthy of its own thread.
If you have a bunch of APK files in a folder, and you want to find out the package name of all of them without having to open each of them, you can use this tip:
[Login to see the link] and put it in the folder of the APK files that you want to see the package names for.
In that folder, type cmd
into the address bar to open command prompt to that location.
Run this command:
for /f "delims=" %i in ('dir /b /on *.apk') do for /f "tokens=2 delims=: " %j in ('aapt dump badging "%i" ^| findstr /r /c:"^package: name="') do echo %~ni %j >> output.txt
You should now have a text file called output.txt
in that folder with the filenames followed by the package names.
Here's how the command works (taken apart by ChatGPT):
- The
for /f
command is a loop that iterates over a set of items. In this case, it's used to iterate over the list of APK files in the current directory.
delims=
specifies the delimiter to use when parsing the input. In this case, the delimiter is set to an empty string, which means that the entire line is used as the input.
%i
and %j
are variables used to store the current item in the loop.
dir /b /on *.apk
lists all the APK files in the current directory, using the /b
switch to output only the file names and the /on
switch to sort the list by name.
aapt dump badging "%i"
is a command that extracts information from an APK file. %i
is replaced by the name of the current APK file in the loop.
^|
is used to escape the |
character, which is a special character in the command prompt.
findstr /r /c:"^package: name="
searches for a line in the output of aapt
that starts with "package: name=". The /r
switch specifies that the search string should be treated as a regular expression.
tokens=2 delims=: "
specifies that the second token (the package name) should be extracted from the output of findstr
, using :
and space as delimiters.
%~ni
is used to extract the file name of the current APK file in the loop, without the file extension.
>> output.txt
redirects the output of the command to a file called "output.txt", using the >>
operator to append the output to the file.
Hope this is helpful!