Modified version of the Chris Pine's image renamer script from Learn to Program