From owner-freebsd-questions@FreeBSD.ORG Wed Oct 24 16:07:23 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2AD6E16A47A for ; Wed, 24 Oct 2007 16:07:23 +0000 (UTC) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: from gizmo.acns.msu.edu (gizmo.acns.msu.edu [35.8.1.43]) by mx1.freebsd.org (Postfix) with ESMTP id E7E6713C481 for ; Wed, 24 Oct 2007 16:07:22 +0000 (UTC) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: from gizmo.acns.msu.edu (localhost [127.0.0.1]) by gizmo.acns.msu.edu (8.13.6/8.13.6) with ESMTP id l9OG4bi8088819; Wed, 24 Oct 2007 12:04:37 -0400 (EDT) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: (from jerrymc@localhost) by gizmo.acns.msu.edu (8.13.6/8.13.6/Submit) id l9OG4bcn088818; Wed, 24 Oct 2007 12:04:37 -0400 (EDT) (envelope-from jerrymc) Date: Wed, 24 Oct 2007 12:04:37 -0400 From: Jerry McAllister To: andrew clarke Message-ID: <20071024160437.GF88476@gizmo.acns.msu.edu> References: <20071024124508.GA17482@ozzmosis.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071024124508.GA17482@ozzmosis.com> User-Agent: Mutt/1.4.2.2i Cc: freebsd-questions@freebsd.org Subject: Re: rename file based on file's timestamp X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Oct 2007 16:07:23 -0000 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"