eskgwin@gmail.com wrote:
> I have a bunch of files that need name changes (about 1000). Each file
> looks like this:
>
> ABC-2008.03.15.19.53.36-2008.03.15.19.54.37.tpd.gz
>
> I need to have the names look like this:
>
> ABC-2008.03.14.19.53.36-2008.03.14.19.54.37.tpd.gz
>
> So, I need to have the day of the month subtracted by 1. The days and
> times are all different from March 2 - March 19.
>
> Is there some ksh or perl script that would make this easy to do?
One way could be this (assuming no spaces in filenames and that day of month
is always the same in first and second occurrence):
cd /dir/wth/the/files
ls | awk -F'.' 'BEGIN {OFS="."}
{o=$0;$3=$8=sprintf("%02d",--$3)

rint"mv "o" "$0}'
if you are fine with the results, then just pipe the output to sh.
--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.