#!/bin/bash # # EXAMPLES: # ./keh_renamepdf.txt 1970 1970 #This script will rename .PDF to .pdf if [ -z "$1" ]; then echo "ERROR: no start year specified" echo "This script expects to be run from a top level directory, with folders of the form YYYY/MM below it" echo "USAGE: ${0} " echo "EXAMPLE: ${0} 1980 1982" fi if [ -z "$2" ]; then echo "ERROR: no stop year specified" echo "This script expects to be run from a top level directory, with folders of the form YYYY/MM below it" echo "USAGE: ${0} " echo "EXAMPLE: ${0} 1980 1982" fi start_year="${1}" stop_year="${2}" for yr in `seq ${start_year} ${stop_year}` do cd $yr echo "$yr" for mo in `seq -w 01 12` do cd $mo echo "$mo" files=`ls *.PDF` for f in ${files[*]} do echo "renaming $f ${f%.PDF}.pdf" mv $f ${f%.PDF}.pdf done cd .. done cd .. done