home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
rescue
/
usr
/
bin
/
old
< prev
next >
Wrap
Text File
|
2006-11-29
|
763b
|
42 lines
#!/bin/bash
#
# This script simply renames files or directories to <name>-<date>[<num>]
#
# Copyright (c) 1996-2002 SuSE Linux AG, Nuernberg, Germany.
#
# please send bugfixes or comments to http://www.suse.de/feedback.
#
#
# usage - tell user to use program
#
function usage() {
echo usage: "$0" file\|dir [file\|dir ...]
}
if [ $# -eq 0 ] ; then
usage
exit
fi
DATESTRING=`date +"%Y%m%d"`
for i in "$@" ; do
i=${i%%/}
if [ -e "$i" ] ; then
NEWNAME=$i-$DATESTRING
NUMBER=0
while [ -e "$NEWNAME" ] ; do
NEWNAME=$i-$DATESTRING-$NUMBER
let NUMBER=$NUMBER+1
done
echo moving "$i" to "$NEWNAME"
mv "$i" "$NEWNAME"
else
echo "$i" does not exist.
fi
done