#!/bin/bash ### # # Run this from within the target directory. For ease of use, you # may want to put this in ~/bin/ if that is in your $PATH variable. # # Start numbering at 1 # ./even-odd-pages.sh * # # Start numbering at 2 # ./even-odd-pages.sh 2 * # ### # If the first parameter is a number use that as starting position if [[ $1 =~ ^[0-9]*$ ]]; then START=$1; shift; else START=1; fi # If file input is not given quit, else continue if [[ ! $1 ]]; then echo -e "\nFile input is required\n"; exit; else # Initialize counter to the start value i=$START # Loop through as sorted list of input files and rename them for x in $@; do echo $x; done | sort -n\ | while read FILENAME; do # Assuming .jpg since this is for images/pages. mv -v $FILENAME ${i}.jpg; # Increment counter ((i+=2)) done fi