Date: Sat, 11 Feb 2023 09:45:32 -0600 From: Tim Daneliuk <tundra@tundraware.com> To: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: remove double quote character from file names Message-ID: <f2fa7836-d93d-37bf-52ef-fe42ee3254b0@tundraware.com> In-Reply-To: <d67caf48-09d6-4864-0b1c-7d64a1a14a76@tundraware.com> References: <d83c93ad-0eac-d41a-c7db-79a1e1bc62d8@nethead.se> <CADqw_gK_3htmJZicOLLODS-MZJUTwV%2BfttBzVEqsP3KztDk10A@mail.gmail.com> <d67caf48-09d6-4864-0b1c-7d64a1a14a76@tundraware.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2/11/23 09:40, Tim Daneliuk wrote: >> On Sat, Feb 11, 2023, 15:59 Per olof Ljungmark <peo@nethead.se <mailto:peo@nethead.se>> wrote: >> >> Hi all, >> >> A little help on the way, I need to find and remove the double quote (") >> character from all files in a directory structure containing hundreds of >> thousands of files. >> >> I am sure plenty of you have done this before... I've gotten as far as >> >> find . -type f -name '*"*' -exec rename 's|"|in|g' {} \; >> find: rename: No such file or directory >> >> The find part works but not renaming so I'm missing something there. >> > > > <Shameless self-promotion follows ;) > > > Some years ago I set about to write the mother of all renaming utilities > exactly because I didn't want to have to go through endless contortions > of sed, gerp, awk, ag, and so forth to do simple renaming tasks like yours. > The result is 'tren' which does what you want rather trivially: > > find ./ -name '*"*' -exec tren -r'"'=X {} \; > > tren can do way more than this (and probably has plenty of undiscovered > edge cases and/or bugs), but I use it regularly and it has vastly simplified > my renaming tasks. > > Code and extensive docs here: > > https://gitbucket.tundraware.com/tundra/tren > > > HTH... > I should have mentioned that - unless you also want your directories renamed - you need to restrict find to pattern matching only on files. Also - it is REALLY STRONG RECOMMENDED - that you do a full backup of the directory tree you're fiddling with. It's very easy to clobber file names during renaming which can wreak all manner of havoc. If you use tren, use the test option extensively until you are CERTAIN it will do what you want. Finally, while running mass renaming operations, I tend to use 'script' to capture the session so I know exactly what was done. -- ---------------------------------------------------------------------------- Tim Daneliuk tundra@tundraware.com PGP Key: http://www.tundraware.com/PGP/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f2fa7836-d93d-37bf-52ef-fe42ee3254b0>