The following script takes a user input (path to a mounted macOS volume such as /Volumes/Macintosh\ HD/)
#!/bin/bash
# Author: Swasti Bhushan Deb
# macOS 10.13.3
# kMDItemWhereFroms.sh
read -e -p "Enter the full path to the Mounted Volume (e.g /Volume /Macintosh HD): " path
var=$(mdfind -name 'kMDItemWhereFroms="*"' -onlyin "$path")
echo "$var"
Output:
/Users/swastibhushandeb/Documents/encase_examiner_v710_release_notes.pdf
/Users/swastibhushandeb/Desktop/AirPrint Forensics.pdf
As a next step I would like the script to perform mdls (prints the values of all the metadata attributes associated with the files) on each output from kMDItemWhereFroms.sh,which can also be perfromed manually by:
mdls /Users/swastibhushandeb/Documents/encase_examiner_v710_release_notes.pdf
However if such processing is to be automated,what are the available bash coding strategies/options available?How can the output be directed to a csv file so that each column contains fields from mdls command output?
mdlson the result ofmdfind) is easy, see answer below. Turning that into a CSV is much harder, that's why it might help to know what you intend to do with the CSV afterwards (as there may be other ways to accomplish this).perl, orpython, orruby, but will require some programming