Therefore, I can almost guarantee that this is a stupid question, but I just cannot understand it. I am trying to count how many times I have indexed files. I need to increment the counter every time I find a PDF file that matches certain criteria (metadata must contain 3 specific values). The variable in question is indexCount, and I highlighted the line where I am trying to increase it with #NOT SURE ABOUT THIS LINE
index() {
for file in *
do
[ -d "$file" ] && (cd "$file"; index)
oldPath=$(pwd)
if [ "$( echo "$file" | grep -E '.*\.pdf' )" ]; then
metadata="$(pdftk "$file" dump_data)"
echo "$metadata" | $(grep -e '^InfoKey: Title' >/dev/null 2>&1) && echo "$metadata" | $(grep -e '^InfoKey: Author' >/dev/null 2>&1) && echo "$metadata" | $(grep -e '^InfoKey: CreationDate' >/dev/null 2>&1)
if [ $? -eq 0 ]; then
path="$(pwd)/""$file"
title=$(getAttr "$metadata" '^InfoKey: Title')
author=$(getAttr "$metadata" '^InfoKey: Author')
creation=$(getAttr "$metadata" '^InfoKey: CreationDate')
authorsArray=($(getAuthors "$author"))
for auth in "${authorsArray[@]}";
do
createFolders "$auth" "$creation" "$title" "$path" "$oldPath"
done
$1=$(($1+1))
fi
fi
done
echo $1
}
indexCount=0
index $indexCount
source
share