Hi Terry,

> > I'd guess apostrophes were in the directory names leading to the
> > files as well as the file's themselves?
> 
> I think that would explain it.

I explicitly limited the find(1) to files based on the problem
description and that renaming directories whilst find is trying to
traverse them can upset it.  :-)

This slightly more complex pipeline would be one solution.

    find -depth -print0 |
    xargs -r0 prename -n '1 while s#'\''([^/]*)$#$1#'

We have find do a depth-first traversal so we know that it's finished
with a directory by the time it prints its path.  The rename is altered
so it only deletes quotes in the final part of the path, IOW a quote
followed by anything that doesn't contain a slash is replaced by that
"anything".  Because this only does one quote yet matches (consumes) to
the end of the string it needs to be done repeatedly in a loop for as
long as it matches.  `1' here is the loop's body, it could be 0 for the
glass-half-empties as it's the loop's condition's side-effect we want.

An alternative to the loop would be a zero-width positive look-ahead
assertion in the pattern as that wouldn't consume to the end of the
string;  I learnt Perl before they existed so that may explain my
picking the loop.  Probably

    ... prename -n 's#'\''(?=[^/]*$)##'

All of this assumes nothing has a name that's solely single quotes.  :-)

Cheers, Ralph.

-- 
Next meeting:  Bournemouth, Tuesday, 2013-01-08 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread on mailing list:  mailto:[email protected]
How to Report Bugs Effectively:  http://goo.gl/4Xue

Reply via email to