Skip to content

Instantly share code, notes, and snippets.

@timtomch
Last active July 3, 2023 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timtomch/a9aa8d1b9079c93159589e51c02d7ef6 to your computer and use it in GitHub Desktop.
Save timtomch/a9aa8d1b9079c93159589e51c02d7ef6 to your computer and use it in GitHub Desktop.
Count Smithsonian objects and list rights available in freetext element
#!/bin/zsh
# This script needs to be run inside the Smithsonian institution folder (where all the 00.txt, 01.txt, ... files are)
setopt extendedglob
echo "Records of type ead_component: "
for file in ^index.txt
do
cat $file |jq -c '. | select(.type=="ead_component") | .id' | wc -l
done | awk '{sum += $1} END {print sum}'
echo "\nRecords of type edanmdm with images: "
edanrecords=$(for file in ^index.txt
do
cat $file |jq -c '. | select((.type=="edanmdm") and (.content.descriptiveNonRepeating.online_media.mediaCount>0)) | .id' | wc -l
done | awk '{sum += $1} END {print sum}')
echo $edanrecords
if [ $edanrecords -gt 0 ]
then
echo "\nRights present for edanmdm records in content.freetext.objectRights:\n"
for file in ^index.txt
do
cat $file |jq -c '. | select((.type=="edanmdm") and (.content.descriptiveNonRepeating.online_media.mediaCount>0) and (.content.freetext.objectRights!=null)) | .content.freetext.objectRights[].content'
done | sort | uniq -c
echo "\nRights present in content.descriptiveNonRepeating.online_media.media.usage.access:\n"
for file in ^index.txt
do
cat $file |jq -c '. | select((.type=="edanmdm") and (.content.descriptiveNonRepeating.online_media.mediaCount>0) and (.content.descriptiveNonRepeating.online_media.media[].usage!=null)) | .content.descriptiveNonRepeating.online_media.media[].usage.access'
done | sort | uniq -c
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment