@vitor I like your example. If I may suggest a compact mdfind alternative:
#!/usr/bin/env zsh
# Perform mdfind search and populate jsonObjects array
while IFS= read -r resultPath; do
jsonObject='{
"uid":"'$resultPath'",
"icon":{"path":"'$resultPath'"},
"arg":"'$resultPath'",
"subtitle":"~'${resultPath/#$HOME/}'",
"title":"'$(basename "$resultPath")'",
"type":"file"
}'
jsonObjects+=("$jsonObject")
done < <(mdfind "kMDItemContentType == 'com.adobe.pdf'" -onlyin ~) # Search PDF files only in home
#done < <(mdfind "*" -onlyin ~ 2>/dev/null) # search all in home
# Convert jsonObjects array to JSON
JSON='{"items":['$(IFS=, ; echo "${jsonObjects[*]}")']}'
# Output JSON
echo "$JSON"
@andy4222 & @vitor To achieve this, would one need to first populate the 'Grid View' with all files and then filter the results using a 'Search Field' of the 'Grid View'?