Get number of frames in scene from the command line?
This information is stored in the blend files header, so you can find out without having to load Blender at all.

This has the advantage you can scan a directory of 100's (or 1000's) of blend files in a very short time (a few seconds even if the files are large).

Blender comes with a script in scripts/modules/blend_render_info.py which can extract this data from a blend file (you don't even need Blender to be installed just a copy of this file and Python is enough).

You can load the script as a module or execute it directly.

command line example:

# python blend_render_info.py /path/to/my_test.blend
1 250 Scene


python example:
This can run inside blender,
otherwise blend_render_info.py will have to be in Python's sys.path

import blend_render_info

filepath = "/path/to/my_test.blend"
frame_start, frame_end, scene = blend_render_info.read_blend_rend_chunk(filepath)

print("total frames:", (frame_end - frame_start) + 1)


As you can see the frame range and active scene is stored, if you want more info you'll have to use a script and load the file into Blender.