0

I have written a script to utilize dexopt-wrapper to odex a folder of .apk's

#!/bin/sh

SYSAPP=/mnt/extSdCard/FilesToOdex/system/app/
SYSPRIVAPP=/mnt/extSdCard/FilesToOdex/system/priv-app/

for i1 in $SYSAPP*.apk ; do
        echo "Odexing $i1..."
        dexopt-wrapper $i1 $i1.odex
done

for i2 in $SYSPRIVAPP*.apk ; do
        echo "Odexing $i2..."
        dexopt-wrapper $i2 $i2.odex
done


for file1 in $SYSAPP*.apk.odex; do
    mv "$file1" "`basename $file1 .apk.odex`$file1.odex"
done
for file2 in $SYSPRIVAPP*.apk.odex; do
    mv "$file2" "`basename $file2 .apk.odex`$file2.odex"
done

The odexing part works, but as you can see it creates a bunch of .apk.odex files

So my question is:

  1. How can I setup the odexing portion to not write the files out as *.apk.odex?
  2. OR, How can I get the mv to properly rename the *.apk.odex files to be just *.odex files?

I tried:

for file1 in $SYSAPP*.apk.odex; do
    mv "${file1}" "${file1%.odex}" 
done
for file2 in $SYSPRIVAPP*.apk.odex; do
    mv "${file2}" "${file2%.odex}"
done

but it turned all my .apk.odex files to .apk

1 Answer 1

2

That's rather a shell scripting question to be asked at Super User. Your answer can be found here: Extract filename and extension in bash:

for file1 in $SYSAPP*.apk.odex; do
    mv "${file1}" "${file1%.*}.odex" 
done
for file2 in $SYSPRIVAPP*.apk.odex; do
    mv "${file2}" "${file2%.*}.odex"
done

should work on most shells, supposedly.

Update:

You can even omit half of your script by adapting this to your original statements: dexopt-wrapper $i1 ${i1%.*}.odex should create the file with the correct naming, so no need to rename it later. To make your script real short and handy:

#!/bin/sh
SYSAPP=/mnt/extSdCard/FilesToOdex/system/app/
SYSPRIVAPP=/mnt/extSdCard/FilesToOdex/system/priv-app/

for i1 in $SYSAPP*.apk $SYSPRIVAPP*.apk; do
    echo "Odexing $i1..."
    dexopt-wrapper $i1 ${i1%.*}.odex
done

That's all you should need :)

5
  • I thought about the rename function as well... on my device it does seem that it is included. I will try this out in a few minutes
    – Kevin
    May 20, 2014 at 14:04
  • 1
    It can be done even easier, see my update ;)
    – Izzy
    May 20, 2014 at 14:56
  • hot digity! That did the trick... now if I can figure out how to get this same script to open up the .apk and remove the classes.dex from it, I'll really be in business LOL
    – Kevin
    May 20, 2014 at 15:24
  • Well, that definitely is beyond a) the scope of this site and b) my knowledge (modifying the .apk itself would break its trust, as you don't have the original key to re-sign it). But glad I was able to help a little at least ;)
    – Izzy
    May 20, 2014 at 15:34
  • :) Yeah, I can go through them on my Linux box open them to browse as .zip files, and remove them that way Much obliged for this!
    – Kevin
    May 20, 2014 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .