The decompiler of IntelliJ IDEA was not built with this kind of usage in mind. It is only meant to help programmers peek at the bytecode of the java classes that they are developing. For decompiling lots of class files of which you do not have source code, you will need some other java decompiler, which is specialized for this job, and most likely runs standalone. If you google you should find a bunch.
Some time ago I used JAD (JAva Decompiler) to achieve this - I do not think IntelliJ's decompiler was incorporated with exporting in mind. It is more of a tool to help look through classes where sources are not available.
JAD is still available for download, but I do not think anyone maintains it anymore: http://varaneckas.com/jad/
There were numerous plugins for it, namely Jadclipse (you guessed it, a way to use JAD in Eclipse - see decompiled classes where code is not available :)).
You could use one of these (you can both use them online or download them, there is some info about each of them) :
http://www.javadecompilers.com/
The one IntelliJ IDEA uses is fernflower, but it can't handle recent things - like String/Enum switches, generics (didn't test this one personally, only read about it), ...
I just tried cfr from the above website and the result was the same as with the built-in decompiler (except for the Enum switch I had in my class).
+ means 1 or more times <source>: file or directory with files to be decompiled. Directories are recursively scanned. Allowed file extensions are class, zip and jar. <destination>: destination directory
Be aware that if you pass it a ".jar" file for the source, it will create another ".jar" file in the destination, however, within the new ".jar" file, the files will be .java instead of .class files (it doesn't explode the jar).
UPDATE
People ask me: How do I get the fernflower.jar?
If you have any IntelliJ product installed, chances are that you already have the Fernflower decompiler on your computer. IntelliJ IDEA comes with Java Bytecode Decompiler plugin (bundled) which is a modern extension of Fernflower.
Locate the file in ${IntelliJ_INSTALL_DIR}\plugins\java-decompiler\lib\java-decompiler.jar (example: C:\Program Files\JetBrains\IntelliJ IDEA 2018\plugins\java-decompiler\lib).
Copy it somewhere and rename to fernflower.jar (optional).
This JAR is not executable, so we can't run it using java -jar. However something like this works:
If you don't have IntelliJ products installed, either download it now (available on jetbrains.com) or make your own decompiler executable from sources (available on Github).
Someone had gave good answers. I made another instruction clue step by step.
First, open your studio and search. You can find the decompier is Fernflower.
IFernflowerPreferences.HIDE_DEFAULT_CONSTRUCTOR to "0",
IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES to "1",
IFernflowerPreferences.REMOVE_SYNTHETIC to "1",
IFernflowerPreferences.REMOVE_BRIDGE to "1",
IFernflowerPreferences.LITERALS_AS_IS to "1",
IFernflowerPreferences.NEW_LINE_SEPARATOR to "1",
**IFernflowerPreferences.BANNER to BANNER,**
IFernflowerPreferences.MAX_PROCESSING_METHOD to 60,
**IFernflowerPreferences.INDENT_STRING to indent,**
**IFernflowerPreferences.IGNORE_INVALID_BYTECODE to "1",**
IFernflowerPreferences.VERIFY_ANONYMOUS_CLASSES to "1",
**IFernflowerPreferences.UNIT_TEST_MODE to if (ApplicationManager.getApplication().isUnitTestMode) "1" else "0")**
I cant find the sutialbe option for the asterisk items.
Like any experienced developer who's being honest, I have to admit it -- I'm lazy. More is less and less is better when it comes to typing. The answers from @naXa and @yan are fine, except for having to open a terminal and type :-(
To decompile a jar right from within intellij, create a reusable JAR Application run configuration:
Copy java-decompiler.jar to a folder in your project (I used lib). Get from:: Windows: C:\Program Files\Intellij\plugins\java-decompiler\lib; or from github (documentation is here)
Copy source jar or class files to same folder
Create a run configuration with settings like these:
Path to JAR: browse to java-decompiler.jar
Program arguments: -hdc=0 -dgs=1 -rsy=1 -lit=1 your.jar lib
Working directory: lib
JRE: 11
In this case, your.jar is the source and lib is the output directory. Save it, run it, and watch it do its thing :-)
Need to do it again with different class files or jars? Duplicate the run config and update Program arguments.