EzWinScore Renaming Shell Script
From Wiki
Jump to navigationJump to search
This is a script to rename the output files from EzWinScore for emailing. I don't like spaces in the names, and the finals files aren't named properly.
#!/bin/sh BASE=`ls -1 | perl -e 'while (<>) { print $1 and exit if ($_ =~ "(.{4}_[0-9]{4}_[0-9]{2}_[0-9]{2})") }'` if [ -z ${BASE} ] ; then echo "*" echo "* Couldn't find any files that matched the regex! Aborting..." echo "*" exit else if [ ! -e "Pistol All divisions.txt" ] ; then echo "*" echo "* Eeek! File 'Pistol All divisions.txt' doesn't exist! Aborting..." echo "*" exit fi if [ ! -e "Pistol Finals All divisions.txt" ] ; then echo "*" echo "* Eeek! File 'Pistol Finals All divisions.txt' doesn't exist! Aborting..." echo "*" exit fi mv "Pistol All divisions.txt" ${BASE}_Pistol_All_Divisions.txt mv "Pistol Finals All divisions.txt" ${BASE}_Pistol_Finals_All_Divisions.txt if [ -e "${BASE}_Single Stack.txt" ] ; then mv "${BASE}_Single Stack.txt" "${BASE}_Single_Stack.txt" fi fi