I am trying to decompile all Java classes contained in a certain directory, starting at the top of the directory.
The directory has many subdirectories and the depth of each one differs.
What I want to do is go into each directory and if the content is a file with suffix
.class, run the decompiler command, which will create a decompiled file in the same directory.
I’ve tried the following but they don’t achieve what I am after.
The first method was:
for dir in ./*; do ( ( if [[ -d $dir ]]; then cd "$dir"; fi ) && ( for f in "$dir"; do ( if [[ -f $f && $f == *".class"* ]]; then jad "$f"; fi ); done ) ); done
The problem here is that it is not recursive. Maybe this can be tweaked in a way that it would be recursive?
The second method was much simpler, but it outputs the files in the top directory. While this might be ok, unfortunately, I have classes that have the same names, but in different packages, so this solution does not work either:
find . -type f -name "*.class" | while read filename; do echo $filename; done
Can one of these be tweaked to achieve what I want? How can the first command be converted to a recursive operation?