aboutsummaryrefslogtreecommitdiff
path: root/bin/pdflinks
blob: ada36e8ede8c8bf45c49667244a76010dd4738c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
#
# Ensure there are PDF links.
#

find data -iname '*.pdf' | grep -v 'screenshot.pdf' | while read line; do
  first="`echo $line  | cut -d '/' -f 2`"
  second="`echo $line | cut -d '/' -f 3`"
  third="`echo $line  | cut -d '/' -f 4`"
  url_base="$(basename "$line")"

  if [ ! -h "$first/$second/$third/$url_base" ]; then
    echo "Processing $first/$second/$third..."
    ( cd data/$first/$second/$third &> /dev/null && find -iname '*.pdf' -exec ln -s {} "$url_base" \;)
  fi
done