Rename Pine sent mail folders

2010/01/06 by Lassi A. Liikkanen

Rename Pine sent mail folders

Mass rename month names to numbers and swap the order of year and month fields in the filename.

You need to customize the ls command embedded in the script to find your files as I have manually renamed (prefixed) the sent mail folder to start with P-

Copy the code below to an executable batch file (tested in GNU BASH 3.00, x86_64-redhat-linux-gnu) and run in the directory containing the files (~/Mail commonly)

#! /bin/bash
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/jan-(....)/1-01/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/feb(....)/1-02/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/mar-(....)/1-03/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/apr-(....)/1-04/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/may-(....)/1-05/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/jun-(....)/1-06/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/jul-(....)/1-07/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/aug-(....)/1-08/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/sep-(....)/1-09/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/oct-(....)/1-10/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/nov-(....)/1-11/'  ) ; done
for i in $( ls P-sent* ) ; do mv $i $( echo ${i} | sed 's/dec-(....)/1-12/'  ) ; done

Thanks to Arsi Moilanen!

Related content:
Several unrelated tips for linux maintenance, 2013/12/08

Bash Shell Script to resolve destinations of T.Co hyperlinks created by Twitter to proper URL , 2013/10/02

Practical guide to using SSH public key identification, 2008/06/25

No comments for this page
Add comment | Show all comments

Name*:
Email*:
Your email will not be shown publicly or disclosed to third parties, it is used to validate messages
Location (City, Country):
* This information must be provided

Keywords: [unix] , [computers] Document's status: Ok (Document dates explained)

This document created: 2010/01/06
Modified: 2010/01/06
Published: 2010/01/06


This document's permanent URI (linking):
http://iki.fi/lassial/guides/unix/100106-Rename_Pine_sent_mail_folders_

© Lassi A. Liikkanen 2010 - 2016. All rights reserved.
^Top of the Page^

*Change layout:
Printable printable
Large text

Myydään:

@lassial Twitter feed: