From owner-freebsd-questions@FreeBSD.ORG Wed Oct 24 12:51:58 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 0352816A417 for ; Wed, 24 Oct 2007 12:51:58 +0000 (UTC) (envelope-from ozzmosis@gmail.com) Received: from smtp.mel.people.net.au (smtp.mel.people.net.au [218.214.17.98]) by mx1.freebsd.org (Postfix) with SMTP id 6568513C480 for ; Wed, 24 Oct 2007 12:51:57 +0000 (UTC) (envelope-from ozzmosis@gmail.com) Received: (qmail 24316 invoked from network); 24 Oct 2007 12:45:11 -0000 Received: from unknown (HELO blizzard.dnsalias.org) (218.215.133.21) by smtp.mel.people.net.au with SMTP; 24 Oct 2007 12:45:11 -0000 Received: by blizzard.dnsalias.org (Postfix, from userid 1001) id E28C71714E; Wed, 24 Oct 2007 22:45:08 +1000 (EST) Date: Wed, 24 Oct 2007 22:45:08 +1000 From: andrew clarke To: freebsd-questions@freebsd.org Message-ID: <20071024124508.GA17482@ozzmosis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.16 (2007-06-09) Subject: 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 12:51:58 -0000 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? Thanks, Regards Andrew