Renaming files

Devin Teske devin.teske at fisglobal.com
Thu Jan 10 05:35:26 UTC 2013


On Jan 9, 2013, at 9:29 PM, Odhiambo Washington wrote:

> I have several files in this format:
> 
> rw-r--r--   1 johndoe johndoe    20085 Jan  9 19:30 1357744249.26989.mbox:2,
> -rw-r--r--   1 johndoe johndoe    24419 Jan  9 19:30
> 1357744250.26989.mbox:2,
> -rw-r--r--   1 johndoe johndoe      418 Jan  9 19:30
> 1357744251.26989.mbox:2,
> -rw-r--r--   1 johndoe johndoe      418 Jan  9 19:30
> 1357744252.26989.mbox:2,
> -rw-r--r--   1 johndoe johndoe    78426 Jan  9 19:30
> 1357744254.26989.mbox:2,
> -rw-r--r--   1 johndoe johndoe     2561 Jan  9 19:30
> 1357744255.26989.mbox:2,
> -rw-r--r--   1 johndoe johndoe     6971 Jan  9 19:30
> 1357744257.26989.mbox:2,
> -rw-r--r--   1 johndoe johndoe    11270 Jan  9 19:30
> 1357744259.26989.mbox:2,
> 
> I'd like to rename them so that the filenames are in the format below:
> 
> -rw-------   1 johndoe johndoe  197702 Jan 10 03:00
> 1357776052.V803I33939aM83469.mail.domain.me.net:2,
> -rw-------   1 johndoe johndoe   14579 Jan 10 03:31
> 1357777873.V803I33939bM614733.mail.domain.me.net:2,
> -rw-------   1 johndoe johndoe   29212 Jan 10 03:46
> 1357778798.V803I33939cM995892.mail.domain.me.net:2,
> -rw-------   1 johndoe johndoe    2834 Jan 10 04:30
> 1357781421.V803I33939dM597872.mail.domain.me.net:2,
> -rw-------   1 johndoe johndoe   10593 Jan 10 06:18
> 1357787890.V803I33939eM865700.mail.domain.me.net:2,
> -rw-------   1 johndoe johndoe   43565 Jan 10 07:10
> 1357791044.V803I33939fM193189.mail.domain.me.net:2,
> -rw-------   1 johndoe johndoe   15492 Jan 10 07:42
> 1357792926.V803I3393a0M601349.mail.domain.me.net:2,
> 
> 
> The first part of the filename is unique, so I just need to substitute
> 26989.mbox:2, with V803I33939aM83469.mail.domain.me.net:2, hoping there
> will be no clash:(
> 

sh -c 'for file in *.26989.mbox:2; do mv $file ${file%%.*}.V803I33939aM83469.mail.domain.me.net:2; done'
-- 
Devin

_____________
The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.


More information about the freebsd-questions mailing list