#December 13, 2012 Karen Horan #!/usr/bin/env bash # # EXAMPLES: #This script will rename files from sun19150809-0356.png to mwil_caiik_fd_19150809_0356.png #Years of data are 1915 - 1984 #It looks for all files ending in .png. I'm adding mwil_caiik_fd_ to the beginning of the date,removing the word sun, #An underscore _ is added after the minutes and the .png will be left as is. #If there is no data in a month, it will be ignored. start_year="${1}" stop_year="${2}" for yr in `seq -w ${start_year} ${stop_year}` do for mo in `seq -w 01 12` do path="${yr}/${mo}" if [ -d ${path} ] then cd ${path} for file in *.png do f2="mwil_caiik_fd_$(echo $file | sed 's/-/_/' | cut -c4-)" mv $file $f2 done cd ../.. else echo "${path} does not exist, continuing" fi done done