2 # ---------------------------------------------------------------------------
3 # Multi-Phasic Applications: SquirrelJME
4 # Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 # Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
6 # ---------------------------------------------------------------------------
7 # SquirrelJME is under the GNU General Public License v3, or later.
8 # See license.mkd for licensing and copyright information.
9 # ---------------------------------------------------------------------------
10 # DESCRIPTION: Renames the given files and moves them under fossil by using
11 # the given regular expression.
16 # Directory of this script
17 __exedir
="$(dirname -- "$0")"
19 # Need at least two arguments
22 echo "Usage: $0 (sed expression) (files...)"
26 # Read the sed expression
30 # Go through all the given files
31 while [ "$#" -ge "1" ]
39 # Get the directory the file is in and its base name
40 __dir
="$(dirname -- "$1")"
41 __fna
="$(basename -- "$1")"
43 # No longer need the argument
46 # Sed transform the file name
47 __tra
="$(echo "$__fna" | sed "$__sed")"
49 # Only rename if the name has changed
50 if [ -n "$__tra" ] && [ "$__tra" != "$__fna" ]
52 # Source and destination
57 if fossil
mv "$__src" "$__dst"
59 mv -v "$__src" "$__dst"