Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to Automator. What I am trying to do as first experiment is automating the process of decompiling a Java class file and immediately after open the decompiled file with its default editor.

Following these instructions I managed to decompile a Java class file using this shell script:

~/bin/jad -lnc -o -d `dirname $1` $1

This will decompile the file class currently selected in the finder. The tool I use (jad) will create in the same directory a file with the same name but a different extension. For example, if the original file was "MyClass.class", then the generated file will be "MyClass.jad".

My question is, how can instruct the Automator to open the generated jad file with its default editor after this being generated in the first action ?

I know I can use the open command in a console to open a file with its default editor, but I do not know how to pass it the right name from Automator.

share|improve this question
up vote 2 down vote accepted

Add open "${1%.*}".jad on a new line at the end of the script. If you want to open it in a specific application (not the default), change it to open -a "Some Application" "${1%.*}".jad

The $1 is the first argument passed to a script, which in this case is the file path. the ${1%.*} strips the extension (i.e. /Users/you/MyClass.class becomes /Users/you/MyClass), and then .jad is appended, so you get the full path of the new file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.