| •1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# MASS RENAME V 1.2 |
| 4 |
# (c) 2000 Giancarlo Erra <[email protected]> |
| 5 |
# This software is under the GNU Public License (GPL) |
| 6 |
# |
| 7 |
# |
| 8 |
# This script is launched by mrename with all necessary parameters |
| 9 |
# Do not launch this script manually. |
| 10 |
# |
| 11 |
# Variables: $2=<prefix> $nnumber=<progressive-number> $mfile=<oldname> |
| 12 |
# |
| 13 |
|
| 14 |
# this is the most untested and buggy string... |
| 15 |
|
| 16 |
mfile=$(echo $1 | sed 's/\.\///') |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
if [ $3 == "copy" ] |
| 21 |
then |
| 22 |
|
| 23 |
number=$(cat ./.mrename-c) |
| 24 |
nnumber=$[$number+1] |
| 25 |
echo "$nnumber" > ./.mrename-c |
| 26 |
|
| 27 |
# This command rename with format <prefix-number-oldname> |
| 28 |
# copying files (that is using cp command) |
| 29 |
|
| •30 |
cp "$mfile" "$2$nnumber$mfile" |
| 31 |
|
| 32 |
# If you want to rename with format <number-prefix-oldname> |
| 33 |
# uncomment the line below |
| 34 |
# |
| 35 |
# cp $mfile $nnumber$2$mfile |
| 36 |
# |
| 37 |
# and comment the previous "cp $mfile $2$nnumber$mfile" |
| 38 |
|
| 39 |
elif [ $3 == "move" ] |
| 40 |
then |
| 41 |
|
| 42 |
number=$(cat ./.mrename-c) |
| 43 |
nnumber=$[$number+1] |
| 44 |
echo "$nnumber" > ./.mrename-c |
| 45 |
|
| 46 |
# This command rename with format <prefix-number-oldname> |
| 47 |
# moving files (that is using mv command) |
| 48 |
|
| •49 |
mv "$mfile" "$2$nnumber$mfile" |
| 50 |
|
| 51 |
# If you want to rename with format <number-prefix-oldname> |
| 52 |
# uncomment the line below |
| 53 |
# |
| 54 |
# mv $mfile $nnumber$2$mfile |
| 55 |
# |
| 56 |
# and comment the previous "mv $mfile $2$nnumber$mfile" |
| 57 |
|
| 58 |
fi |
| 59 |
|
| 60 |
# THE END ;) |