From owner-freebsd-questions@FreeBSD.ORG Wed Oct 24 13:07:11 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 17E3A16A417 for ; Wed, 24 Oct 2007 13:07:11 +0000 (UTC) (envelope-from wundram@beenic.net) Received: from mail.beenic.net (mail.beenic.net [83.246.72.40]) by mx1.freebsd.org (Postfix) with ESMTP id DF66013C4A5 for ; Wed, 24 Oct 2007 13:07:10 +0000 (UTC) (envelope-from wundram@beenic.net) Received: from [192.168.1.37] (a89-182-24-56.net-htp.de [89.182.24.56]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.beenic.net (Postfix) with ESMTP id 0ECAFA44529 for ; Wed, 24 Oct 2007 15:01:43 +0200 (CEST) From: "Heiko Wundram (Beenic)" Organization: Beenic Networks GmbH To: freebsd-questions@freebsd.org Date: Wed, 24 Oct 2007 15:07:04 +0200 User-Agent: KMail/1.9.7 References: <20071024124508.GA17482@ozzmosis.com> In-Reply-To: <20071024124508.GA17482@ozzmosis.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710241507.04740.wundram@beenic.net> 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 13:07:11 -0000 Am Mittwoch, 24. Oktober 2007 14:45:08 schrieb andrew clarke: > 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? Simple bash script to do this (untested): for i in $* do mv $i `stat -f %Sm -t %Y-%m-%d`.mp3 done HTH! -- Heiko Wundram Product & Application Development