From owner-freebsd-questions@FreeBSD.ORG Wed Oct 24 14:26:50 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 28F5016A418 for ; Wed, 24 Oct 2007 14:26:50 +0000 (UTC) (envelope-from gahr@gahr.ch) Received: from cpanel03.rubas-s03.net (cpanel03.rubas-s03.net [195.182.222.73]) by mx1.freebsd.org (Postfix) with ESMTP id EAB5B13C491 for ; Wed, 24 Oct 2007 14:26:49 +0000 (UTC) (envelope-from gahr@gahr.ch) Received: from town.bfh.ch ([147.87.98.171]) by cpanel03.rubas-s03.net with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1IkhBq-0003AD-DA; Wed, 24 Oct 2007 16:26:34 +0200 Message-ID: <471F5618.4040202@gahr.ch> Date: Wed, 24 Oct 2007 16:26:32 +0200 From: Pietro Cerutti User-Agent: Thunderbird 1.5.0.9 (X11/20070104) MIME-Version: 1.0 To: "Heiko Wundram (Beenic)" , freebsd-questions@freebsd.org References: <20071024124508.GA17482@ozzmosis.com> <200710241507.04740.wundram@beenic.net> In-Reply-To: <200710241507.04740.wundram@beenic.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel03.rubas-s03.net X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gahr.ch X-Source: X-Source-Args: X-Source-Dir: Cc: 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 14:26:50 -0000 Heiko Wundram (Beenic) wrote: > 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 just pay attention at the situation when two files have the same timestamp.. > > HTH! > -- Pietro Cerutti PGP Public Key: http://gahr.ch/pgp