How to view a PE EXE/DLL file version information?

I'm working in a tool called pev to retrieve information about PE files on the command line.

It is installable with

sudo apt-get install pev

The file version can be fetched with

peres -v program.exe | awk '{print $3}'

From the gnome-exe-thumbnailer script, suggested by Scott Ritchie:

wrestool --extract --raw --type=version inputfile.exe

extracts the version information, printing some binary data mixed with UTF-16 text. The script converts it to readable text by piping it through:

tr '\0, ' '\t.\0' \
| sed 's/\t\t/_/g' \
| tr -c -d '[:print:]' \
| sed -r -n 's/.*Version[^0-9]*([0-9]+\.[0-9]+(\.[0-9][0-9]?)?).*/\1/p'

The overall command is then wrestool --extract --raw --type=version inputfile.exe | tr '\0, ' '\t.\0' | sed 's/\t\t/_/g' | tr -c -d '[:print:]' | sed -r -n 's/.*Version[^0-9]*([0-9]+\.[0-9]+(\.[0-9][0-9]?)?).*/\1/p'.


As an alternative to using tr and sed to parse the output from @mechanical-snail 's solution, here is a GNU strings and GNU grep version:

$ wrestool --extract --raw --type=version putty.exe | strings -el | grep Version -A 1

FileVersion
Release 0.65
ProductVersion
Release 0.65

UPDATE:

Another alternative is a recent version of exiftool by Phil Harvey (it is based on perl, easy to install with sudo apt-get install libimage-exiftool-perl, also available for Mac and Windows). It has lots of formatting options.

# Example with exiftool 10.47
$ exiftool -FileVersion -ProductVersion putty.exe

File Version                    : Release 0.67
Product Version                 : Release 0.67

Tags:

Wine