Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Oct 2007 16:26:32 +0200
From:      Pietro Cerutti <gahr@gahr.ch>
To:        "Heiko Wundram (Beenic)" <wundram@beenic.net>,  freebsd-questions@freebsd.org
Subject:   Re: rename file based on file's timestamp
Message-ID:  <471F5618.4040202@gahr.ch>
In-Reply-To: <200710241507.04740.wundram@beenic.net>
References:  <20071024124508.GA17482@ozzmosis.com> <200710241507.04740.wundram@beenic.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?471F5618.4040202>