Date: Thu, 16 Feb 2023 08:20:09 +0100 (CET) From: Sysadmin Lists <sysadmin.lists@mailfence.com> To: freebsd-questions@freebsd.org Cc: Per olof Ljungmark <peo@nethead.se> Subject: Re: remove double quote character from file names Message-ID: <1398045780.627028.1676532009651@ichabod.co-bxl> In-Reply-To: <d83c93ad-0eac-d41a-c7db-79a1e1bc62d8@nethead.se> References: <d83c93ad-0eac-d41a-c7db-79a1e1bc62d8@nethead.se>
next in thread | previous in thread | raw e-mail | index | archive | help
---------------------------------------- > From: Per olof Ljungmark <peo@nethead.se> > Date: Feb 11, 2023, 6:58:50 AM > To: <freebsd-questions@freebsd.org> > Subject: remove double quote character from file names > > > 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. > > Thanks, > Per > > Just to throw in an awk-themed solution: $ ls -1 | awk '/"/ { system("mv -v '\''" $0 "'\'' " $0) }' $ touch "\"foo bar\"" \"baz\" \".zap\" xyz abc $ ls -1A ".zap" "baz" "foo bar" abc xyz $ ls -1 | awk '/"/ { system("mv -v '\''" $0 "'\'' " $0) }' ".zap" -> .zap "baz" -> baz "foo bar" -> foo bar $ ls -1A .zap abc baz foo bar xyz There's a clever use of the existing double-quotes in the filenames in the renaming. -- Sent with https://mailfence.com Secure and private email
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1398045780.627028.1676532009651>