How to view DMG contents without mounting it

For an auto-install macro I'm currently writing (which mainly deals with pkg and audio plug-ins file types like vst(3), component etc.), I would like to be able to view the content of a dmg file without mounting it (through Terminal, AppleScript, Javascript or KM).
Specifically:

  • if the DMG contains PKG files, choose option #1;
  • if the DMG contains other file types, choose option #2, #3 etc., depending on the file extension.

Is this feasible at all?
Thank you,
Jan

A long shot to view the contents of a disk image without mounting it, I think.

There's apparently a contextual menu option to peek inside. See: How Can I Look Into a .DMG File.

Pacifist also claims to work.

2 Likes

Thank you for answering, @complexpoint and @mrpasini.
After quite a bit of research, I found a decent solution with 7-zip (through Homebrew) on Terminal.

An example might be the following (with grep and some basic RegEx):
7z l <path_filename.dmg> | grep .pkg$

This way, only the first occurrence of "pkg" is shown (if present), skipping the extra content inside the pkg package.
I still have to understand how to get the filename only with grep (the -l option doesn't seem to work), but it's more than enough for my purpose.

Thanks,
J

1 Like