Date: Wed, 24 Oct 2007 12:04:37 -0400 From: Jerry McAllister <jerrymc@msu.edu> To: andrew clarke <ozzmosis@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: rename file based on file's timestamp Message-ID: <20071024160437.GF88476@gizmo.acns.msu.edu> In-Reply-To: <20071024124508.GA17482@ozzmosis.com> References: <20071024124508.GA17482@ozzmosis.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Oct 24, 2007 at 10:45:08PM +1000, andrew clarke wrote: > Hi, > > Hopefully, a simple request... > > I have a series of files in a directory: > > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Jul 28 2006 209.mp3 > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Jul 31 2006 212.mp3 > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Aug 1 2006 213.mp3 > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Aug 2 2006 214.mp3 > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Aug 3 2006 215.mp3 > > etc. > > Now I want to rename these so the new filenames are based on the file's > timestamp, like so: > > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Jul 28 2006 2006-07-28.mp3 > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Jul 31 2006 2006-07-31.mp3 > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Aug 1 2006 2006-08-01.mp3 > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Aug 2 2006 2006-08-02.mp3 > -rw-r--r-- 1 ozzmosis ozzmosis 115201253 Aug 3 2006 2006-08-03.mp3 > > I can write some Python code to do this, but maybe there is another way, > perhaps using a shell script. Any thoughts? A script is a script whether it is in Python, Perl or one of the common shells. Use what works for you. I'd use Perl, but I am already somewhat familiar with Perl. ////jerry > > Thanks, > > Regards > Andrew > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071024160437.GF88476>