On 15/12/12 13:26, Terry Coles wrote:
Hi,
Anyone got a good bash incantation for removing apostrophes in lots of file-
names? I assume that it could be done with a combination of mv (or rename)
and grep, but maybe there is a better way.
I've just ripped a collection of audio CDs to ogg format for transfer to my
audio player, but (like most of these devices) it has a FAT32 file-system,
which can't cope with apostrophes.
Last time I did this, I changed them in the file manager, but this time I've
got about 150 tracks, most of which use apostrophes to delineate the title of
the piece.
There are 11 folders, so the script or command needs to be recursive.
Sorry Terry, no script for you, but the built-in rename command works
nicely for me when renaming files in a single directory:
sean@bender:~$ rename -v 's/'\'//'' *.txt
sean's_file.txt renamed as seans_file.txt
sean@bender:~$ rename -v 's/'\'//'g' *.txt
sean's_file's.txt renamed as seans_files.txt
Two examples there - the first with a single apostrophe and the second
with two (or many) apostrophes (and a dreadful grammatical error!).
I imagine that you can combine that with the find command somehow to get
it to search directories recursively and rename the files it finds with
apostrophes.
That said there is probably a much cleverer way to do it!
Sean
--
music, film, comics, books, rants and drivel:
www.funkygibbins.me.uk
--
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