Skip site navigation (1)Skip section navigation (2)
Date:      Mon,  7 Mar 2005 09:22:12 -0800
From:      joseph kacmarcik <freebsd-questions@chubbo.net>
To:        Phusion <phusion2k@gmail.com>
Cc:        questions@freebsd.org
Subject:   Re: Help Renaming Multple Files
Message-ID:  <1110216132.422c8dc4df808@mail.chubbo.net>
In-Reply-To: <c3ed3fdc050307083572c03627@mail.gmail.com>
References:  <c3ed3fdc050307083572c03627@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

> I need help figuring out how to rename multple files. The files are
> named like reports_abcdef_YYYYMMDD.dat, reports_hijklm_YYYYMMDD.dat,
> and reports_nopqrs_YYYYMMDD.dat. Here is an example.
> 
> Original Filename: reports_abcdef_YYYYMMDD.dat
> New Filename: abcdef_YYYYMMDD.dat
> 
> Let me know how I can do this. Thanks.

there are plenty of methods for this. one is:

for file in `ls -1 /path/to/files`; do
mv $file `echo $file | sed -e 's/^reports_//g'`
done

joe



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