Help Renaming Multple Files

joseph kacmarcik freebsd-questions at chubbo.net
Mon Mar 7 09:22:13 PST 2005


> 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


More information about the freebsd-questions mailing list