Hi Terry,

> > > Anyone got a good bash incantation for removing apostrophes in
> > > lots of filenames?
> >
> >     find -type f -print0 | xargs -r0 prename -n "s/'//g"
> 
> I couldn't get that to work as advertised.  If I did it as written
> above, it did what you said and printed out what it would do.  When I
> removed the '-n' it refused to work at all saying that the file or
> folder didn't exist.

I'd guess apostrophes were in the directory names leading to the files
as well as the file's themselves?

> This may be a red herring, because I also had path length issues on
> the FAT32 partition, so that may have been the cause.  However, if so,
> why did it apparently work with the '-n'?

The -n has it merely print what it would do so there's no opportunity
for the filesystem to indicate an error with what's to be attempted;
it's not involved.  If a directory had a slash that was also removed by
prename then the destination directory wouldn't exist, e.g. if would
fail as if

    led_zepplin's_mothership/208-nobody's_fault_but_mine.mp3

was mv(1)'d to

    led_zepplins_mothership/208-nobodys_fault_but_mine.mp3

mv would complain that the directory led_zepplins_mothership didn't
exist;  that's right.

> In the end, I used Sean's version, which worked fine once I'd got the
> folder names short enough.

Being in the directory has removed the directory name and any
apostrophe's in them from being altered by the substitution?

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