On Tue, 27 May 2003, Vince Hoffman wrote: > > > This is certainly not freeBSD specific and probably I'm annoying > > someone for being off-topic but please be patient and hint me on where > > to find good resources in shell-programming. > > > http://www.shelldorado.com/ > isnt bad. otherwise comp.unix.shell is always worth a look. > > > > > > > I could use some help in writing a script that renames all files in a > > directory tree to the files last modified date, example usage: > > > > > daterename "Img_" *.jpg > > > > the command above will rename all *.jpg files to "Imag_<date>".jpg
============================= #!/bin/tcsh set prefix=$1 shift while ( "$1" != "" ) set ext=`expr "$1" : ".*\(\..*\)"` set newname=$prefix`stat -f "%Sm" -t "%F_%H:%M:%S"` echo moving $1 to $newname$ext mv $1 $newname$.ext shift end =========================== BUGS: I'm not sure "stat" works in 4.x If two [or more] files are created at exactly the same time, the one with the last name --in lexicographic order-- will overwrite the others. Hope it helps. _______________________________________________ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"