At the present time on my local disk I have 88 .dmg files, three of which are encrypted. Before running the command line below I didn't know how many encrypted .dmg files I had and if any, where they were. So while the following command line may look convoluted nonetheless it should work as advertised.
Open Terminal and copy and paste the entire command line below, as is, into the Terminal then press Enter.
mdfind '(kMDItemFSName=*.dmg)' | while IFS= read -r line; do printf "$line " & hdiutil isencrypted "$line"; done > dmg_file_list; grep ': YES' dmg_file_list > encrypted_dmg_file_list; clear; cat encrypted_dmg_file_list
This will create two files, dmg_file_list and encrypted_dmg_file_list, and output the contents of the latter to the Terminal. The files can also be opened in a text editor.
The files will contain the fully qualified pathname of the .dmg files followed by a space and either encrypted: NO or encrypted: YES in the dmg_file_list file and only the fully qualified pathname of the .dmg files followed by a space and encrypted: YES in the encrypted_dmg_file_list file.
You can then manually delete the two files created by the command when finished with them.
Note: Once the command line is executed if may take a moment to process and output the contents of the encrypted_dmg_file_list file to the Terminal. It will depend on just how many .dmg files there are.
Here is the full command line shown with line continuation so you make sure to copy and paste the entire line. (You can actually copy and paste the command line in this format too.)
mdfind '(kMDItemFSName=*.dmg)' | while IFS= read -r line; \
do printf "$line " & hdiutil isencrypted "$line"; \
done > dmg_file_list; grep ': YES' dmg_file_list > encrypted_dmg_file_list; \
clear; cat encrypted_dmg_file_list
.dmg
files, e.g. usingls -l@
might showcom.apple.metadata:kMDItemDownloadedDate
there is not acom.apple.metadata:kMDItemEncrypted
. You can see the metadata attributes of a file usingmdls
. So usinghdiutil imageinfo
is probably the only way to get directly from the file itself. You could script it and pipe the output ofhdiutil imageinfo
togrep
, etc. and further process it so the final output might be list of files that are encrypted, etc. It all depends on really what you're trying to accomplish to begin with.