Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Feb 2023 13:40:27 -0500
From:      Paul Procacci <pprocacci@gmail.com>
To:        Kurt Hackenberg <kh@panix.com>
Cc:        questions@freebsd.org
Subject:   Re: remove double quote character from file names
Message-ID:  <CAFbbPuh1cAEVAxQe0XBwkdTh2KTK3XUGEZcYGv8_7sLDzi5--w@mail.gmail.com>
In-Reply-To: <Y%2BffFccEVhLCFBMP@rain.cave>
References:  <d83c93ad-0eac-d41a-c7db-79a1e1bc62d8@nethead.se> <Y%2BffFccEVhLCFBMP@rain.cave>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Sat, Feb 11, 2023 at 1:32 PM Kurt Hackenberg <kh@panix.com> wrote:

> On Sat, Feb 11, 2023 at 03:58:50PM +0100, Per olof Ljungmark wrote:
>
> >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.
>
> That's nasty. Be careful, keep backups.
>
> I might use a full-on programming language -- maybe Python or Ruby --
> to avoid the difficulties of shell parsing and quoting. However, if you
> want to do it through a shell, this might be helpful:
>
> <https://dwheeler.com/essays/filenames-in-shell.html>;
>
>
My way.  Doesn't account for spaces in filenames, but that's easily added
with -print0 flags to find and -0 flags to xargs:

ls *\"* | perl -lne '$n=$_;$n=~tr/"//d;rename($_,$n);'

~Paul

-- 
__________________

:(){ :|:& };:

[-- Attachment #2 --]
<div dir="ltr"><div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 11, 2023 at 1:32 PM Kurt Hackenberg &lt;<a href="mailto:kh@panix.com">kh@panix.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sat, Feb 11, 2023 at 03:58:50PM +0100, Per olof Ljungmark wrote:<br>
<br>
&gt;A little help on the way, I need to find and remove the double quote (&quot;)<br>
&gt;character from all files in a directory structure containing hundreds of<br>
&gt;thousands of files.<br>
<br>
That&#39;s nasty. Be careful, keep backups.<br>
<br>
I might use a full-on programming language -- maybe Python or Ruby -- <br>
to avoid the difficulties of shell parsing and quoting. However, if you <br>
want to do it through a shell, this might be helpful:<br>
<br>
&lt;<a href="https://dwheeler.com/essays/filenames-in-shell.html" rel="noreferrer" target="_blank">https://dwheeler.com/essays/filenames-in-shell.html</a>&gt;<br>;
<br>
</blockquote></div><br>My way.  Doesn&#39;t account for spaces in filenames, but that&#39;s easily added with -print0 flags to find and -0 flags to xargs:<br><br clear="all">
ls *\&quot;* | perl -lne &#39;$n=$_;$n=~tr/&quot;//d;rename($_,$n);&#39;

<br><br></div><div>~Paul</div><div><br></div><div>-- <br><div dir="ltr" class="gmail_signature">__________________<br><br>:(){ :|:&amp; };:</div></div></div>
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFbbPuh1cAEVAxQe0XBwkdTh2KTK3XUGEZcYGv8_7sLDzi5--w>