From nobody Sat Nov 30 17:23:08 2024 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 4Y0xhd2hGQz5fM2W for ; Sat, 30 Nov 2024 17:23:13 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from ms-10.1blu.de (ms-10.1blu.de [178.254.4.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y0xhc2TWJz43vW for ; Sat, 30 Nov 2024 17:23:12 +0000 (UTC) (envelope-from guru@unixarea.de) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of guru@unixarea.de designates 178.254.4.101 as permitted sender) smtp.mailfrom=guru@unixarea.de; dmarc=none Received: from [62.216.207.182] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tHRBV-00ACBn-RK for freebsd-questions@freebsd.org; Sat, 30 Nov 2024 18:23:09 +0100 Received: from localhost.my.domain (c720-1400094 [127.0.0.1]) by localhost.unixarea.de (8.17.1/8.14.9) with ESMTP id 4AUHN9nR003026 for ; Sat, 30 Nov 2024 18:23:09 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.17.1/8.14.9/Submit) id 4AUHN9hD003025 for freebsd-questions@freebsd.org; Sat, 30 Nov 2024 18:23:09 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Sat, 30 Nov 2024 18:23:08 +0100 From: Matthias Apitz To: freebsd-questions@freebsd.org Subject: Re: shell script for removing unprintable characters in file names Message-ID: Reply-To: Matthias Apitz Mail-Followup-To: freebsd-questions@freebsd.org References: <95966dac-9d93-401f-9948-5fcb224a1e1f@nethead.se> <86v7w464zp.fsf@bay.localnet> List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-questions@freebsd.org Sender: owner-freebsd-questions@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86v7w464zp.fsf@bay.localnet> X-Operating-System: FreeBSD 14.0-CURRENT r1400094 (amd64) X-message-flag: Mails in HTML will not be read! Please, only plain text. X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 62.216.207.182 X-Spamd-Result: default: False [-2.89 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.992]; MID_RHS_NOT_FQDN(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:178.254.4.101]; RCVD_IN_DNSWL_LOW(-0.10)[178.254.4.101:from]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DMARC_NA(0.00)[unixarea.de]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; HAS_XAW(0.00)[]; ASN(0.00)[asn:42730, ipnet:178.254.0.0/19, country:DE]; HAS_REPLYTO(0.00)[guru@unixarea.de]; TO_DN_NONE(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MISSING_XM_UA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; HAS_XOIP(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[] X-Rspamd-Queue-Id: 4Y0xhc2TWJz43vW X-Spamd-Bar: -- El día sábado, noviembre 30, 2024 a las 08:50:02a. m. -0800, Carl Johnson escribió: > Per olof Ljungmark writes: > > > Hi, > > > > I am tasked with recovering hundreds or more files created with > > unknown OSs and have unknown characters in the name, replaced with a > > '?'. > > > > Like file?nam?.??? > > > > Please, if you have such a script can you post or email it? Replacing > > the unknown character with anything, like '-' or '_' using whatever > > shell, sh, bash or csh. > You can use the 'file' command to see in which charset the file are encoded, ISO-8859-1 or UTF-8 or ... And then the command 'iconv' to convert them to the charset you need. matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub Annalena Baerbock: "We are fighting a war against Russia ..." (25.1.2023) I, Matthias, I am not at war with Russia. Я не воюю с Россией. Ich bin nicht im Krieg mit Russland.