From nobody Thu Feb 16 07:20:09 2023 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PHRDH21lgz3pH7f for ; Thu, 16 Feb 2023 07:20:15 +0000 (UTC) (envelope-from sysadmin.lists@mailfence.com) Received: from wilbur.contactoffice.com (wilbur.contactoffice.com [212.3.242.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4PHRDG2VvLz3FDJ for ; Thu, 16 Feb 2023 07:20:13 +0000 (UTC) (envelope-from sysadmin.lists@mailfence.com) Authentication-Results: mx1.freebsd.org; dkim=fail ("body hash did not verify") header.d=mailfence.com header.s=20210208-e7xh header.b=i11EY4p5; spf=pass (mx1.freebsd.org: domain of sysadmin.lists@mailfence.com designates 212.3.242.68 as permitted sender) smtp.mailfrom=sysadmin.lists@mailfence.com; dmarc=pass (policy=quarantine) header.from=mailfence.com Received: from ichabod.co-bxl (ichabod.co-bxl [10.2.0.36]) by wilbur.contactoffice.com (Postfix) with ESMTP id 3F82A1020; Thu, 16 Feb 2023 08:20:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1676532011; s=20210208-e7xh; d=mailfence.com; i=sysadmin.lists@mailfence.com; h=Date:From:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; l=1206; bh=ifFS6rG5ZR1r6zPVOvwwVVi7pKmVL17MEP3WNUumoA4=; b=i11EY4p5xLdG1EqKueNJXw6ovtHwdpxYZoiNkqshEPZoGKGQrVW1JItc/a+j0557 o7y5U54ze/pqamQCV7nRKNr+vyq+P1EXjbep9+r2Aoor06SFrFutuG1U+avjBwn0GS5 sKReEeY0jrlWiXJD8kY+UiJRZrsPvH/SZQwRQ2CEODyc1I0RC8VTYbEes6ost++/teg TOWpqOfUiRKvNKHjSFsNT39+FL7XaDN9yddCMiwffoQQGhNmJ7AueRlXixaQB+cg5sF n8fMGeyDb1TdISYwrEijEHakZap0eAaXyL0xyA7j3eLZySXRl0ojMYtKsWVKghH6vU1 qVULFRLHsQ== Date: Thu, 16 Feb 2023 08:20:09 +0100 (CET) From: Sysadmin Lists To: freebsd-questions@freebsd.org Message-ID: <1398045780.627028.1676532009651@ichabod.co-bxl> In-Reply-To: References: Subject: Re: remove double quote character from file names List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Per olof Ljungmark X-Mailer: ContactOffice Mail X-ContactOffice-Account: com:312482426 X-Spamd-Result: default: False [-3.75 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.997]; NEURAL_HAM_MEDIUM(-0.86)[-0.863]; DMARC_POLICY_ALLOW_WITH_FAILURES(-0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:212.3.242.64/26]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[212.3.242.68:from]; XM_UA_NO_VERSION(0.01)[]; ASN(0.00)[asn:10753, ipnet:212.3.242.64/26, country:US]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[mailfence.com:-]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; DMARC_POLICY_ALLOW(0.00)[mailfence.com,quarantine]; R_DKIM_REJECT(0.00)[mailfence.com:s=20210208-e7xh]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 4PHRDG2VvLz3FDJ X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N ---------------------------------------- > From: Per olof Ljungmark > Date: Feb 11, 2023, 6:58:50 AM > To: > 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