
#
# Recover from llgal_jer directory rename moving *.jpg files up one directory
#

for FI in 20131*
do
    DIRNAME=`echo  "${FI}" | sed -e "s/^2013//g" \
      -e "s/-DCFC.*jpg//g" \
      -e "s/-DCFN.*jpg//g" \
      -e "s/2008-09-ANK-CAP-LO.*/2008-09-ANK-CAP-LO/g" \
      -e "s/2008-09-ANK-CAP-LO.*/2008-09-ANK-CAP-LO/g" \
      -e "s/2008-07-28-Oshkosh.*/2008-07-28-Oshkosh/g" \
      -e "s/2008-06-15-Hobbs-BDU.*/2008-06-15-Hobbs-BDU/g" \
      -e "s/2008-09-20-LXV-Eisenhower-Loveland-Pass.*/2008-09-20-LXV-Eisenhower-Loveland-Pass/g" \
      -e "s/2008-09-18-CB.*/2008-09-18-CB/g" \
      -e "s/2006-Lava-Hot-Springs-ID-Lava.*/2006-Lava-Hot-Springs-ID/g" \
      -e "s/Moriah-Graduation-CSU.*/Moriah-Graduation-CSU/g" \
      -e "s/-img-.*//g" \
      -e "s/2009-07-Oshkosh.*/2009-07-Oshkosh/g" \
      -e "s/2009-10-N221CP.*/2009-10-N221CP/g" \
      -e "s/2010-04-13-Sun-N-Fun.*/2010-04-13-Sun-N-Fun/g" \
      -e "s/2009-07-Mtn-Fly-1.*/2009-07-Mtn-Fly-1/g" \
      -e "s/2009-07-Mtn-Fly-2.*/2009-07-Mtn-Fly-2/g" \
      -e "s/2009-09-Elk-Park-Airport-CO.*/2009-09-Elk-Park-Airport-CO/g" \
      -e "s/2009-03-24-Saint-Louis.*/2009-03-24-Saint-Louis/g" \
      -e "s/2008-08-20-Leadville.*/2008-08-20-Leadville/g" \
      -e "s/2011-03-29-Sun-N-Fun.*/2011-03-29-Sun-N-Fun/g" \
      -e "s/2010-08-28-Durango-EAA-Fly-in.*/2010-08-28-Durango-EAA-Fly-in/g" \
      -e "s/2010-N221CP-Applebay.*/2010-N221CP-Applebay/g" \
      -e "s/1997-06-05-Quarter-Circle-Circle-Ranch.*/1997-06-05-Quarter-Circle-Circle-Ranch/g" \
      -e "s/Hawaii-img.*jpg/Hawaii/g"`

    BASEFI=`echo  "${FI}" | sed \
      -e "s/.*-DCFC/DCFC/g" \
      -e "s/.*-DCFN/DCFN/g" \
      -e "s/.*ID-Lava-Hot-Springs-ID/Lava-Hot-Springs-ID/g" \
      -e "s/.*2008-09-ANK-CAP-LO-P/P/g" \
      -e "s/.*2008-09-ANK-CAP-LO-P/P/g" \
      -e "s/.*2008-07-28-Oshkosh-0/0/g" \
      -e "s/.*2008-06-15-Hobbs-BDU-img/img/g" \
      -e "s/.*2008-09-20-LXV-Eisenhower-Loveland-Pass-img/img/g" \
      -e "s/.*2008-09-18-CB-img/img/g" \
      -e "s/.*Moriah-Graduation-CSU-img/img/g" \
      -e "s/.*-img-/img-/g" \
      -e "s/.*2009-07-Oshkosh-S/S/g" \
      -e "s/.*2009-10-N221CP-N221CP/N221CP/g" \
      -e "s/.*2010-04-13-Sun-N-Fun-//g" \
      -e "s/.*2009-07-Mtn-Fly-1-//g" \
      -e "s/.*2009-07-Mtn-Fly-2-//g" \
      -e "s/.*2009-09-Elk-Park-Airport-CO-img/img/g" \
      -e "s/.*2009-03-24-Saint-Louis-//g" \
      -e "s/.*2008-08-20-Leadville-//g" \
      -e "s/.*2011-03-29-Sun-N-Fun-//g" \
      -e "s/.*2010-08-28-Durango-EAA-Fly-in-//g" \
      -e "s/.*2010-N221CP-Applebay-//g" \
      -e "s/.*1997-06-05-Quarter-Circle-Circle-Ranch-//g" \
      -e "s/.*Hawaii-img/img/g"`

    if [ -d "${DIRNAME}" ]; then  # If it is a directory, move the file back.
        echo mv "${FI}" "${DIRNAME}"/"${BASEFI}"
             mv "${FI}" "${DIRNAME}"/"${BASEFI}"
    fi
#    else			  # more work to do
#	echo "Not a directory: DIRNAME=\"${DIRNAME}\"" > NOT-DIR
done | more

