david wrote:
A directory with files of unknown names.

I want to rename each seperate file with it's date/time thus:

-rw-r--r-- 1 david david 105 2007-01-19 11:20 test

becomes
-rw-r--r-- 1 david david 105 2007-01-19 11:20 200701191120

I've been messing with it for a few hours, and I'm sure it's simple but
I'm not getting there.

Hooray for Friday afternoon scripting fun!

This isn't pretty, but will probably work[*]. Except on files with spaces.

for file in `ls`; do
 date=`ls -l --time-style=long-iso "$file" | awk '{ print "$6 $7" }'
 newname=`date -d "$date" +%Y%m%d%H%M`
 mv "$file" $newname

* Only partially tested. Your mileage liable to variance.

--
Pete
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to