1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#!/bin/sh
error="true"
name1="$1"
name2="$2"
dir1=""
dir2=""
if test -d "$1"; then
dir1="$1/"
name1="$2"
if test $# -eq 4; then
dir2="$3/"
name2="$4"
elif test $# -eq 3; then
name2="$3"
fi
elif test -d "$2"; then
dir2="$2/"
if test $# -eq 3; then
file2="$3"
else
file2="$1"
fi
fi
for prefix in b s d c; do
file1="$dir1$prefix.$name1"
file2="$dir2$prefix.$name2"
if test $prefix = "c"; then
if cp -f "$file1" "$file2" 2> /dev/null; then
echo "Copying $file1 to $file2 ... done"
unset error
fi
elif mv -f "$file1" "$file2" 2> /dev/null; then
echo "Renaming $file1 as $file2 ... done"
unset error
fi
done
if test -n "$error"; then
echo "Renaming: no files found for $dir1[bsdc].$name1 and $dir2[bsdc].$name2"
fi
|