Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Feb 2023 13:46:46 -0500
From:      Scott Ballantyne <boyvalue@gmail.com>
To:        Per olof Ljungmark <peo@nethead.se>
Cc:        questions@freebsd.org
Subject:   Re: remove double quote character from file names
Message-ID:  <CAESeg0z1ygZQkLZoPhYcSchnrvKJf0zLh7P_89gDDcw3MDBdEA@mail.gmail.com>
In-Reply-To: <CAESeg0w9u96AiGrvip8yTpaEMZyU93Fpx83-nwe1ysW586o--A@mail.gmail.com>
References:  <d83c93ad-0eac-d41a-c7db-79a1e1bc62d8@nethead.se> <CADqw_gK_3htmJZicOLLODS-MZJUTwV%2BfttBzVEqsP3KztDk10A@mail.gmail.com> <CAESeg0xnUiFnvRkRGnHAO5TKq-HMyygM0afTNZqHc7zrwV%2BFZQ@mail.gmail.com> <e752f769-b5a5-9763-448f-fe599a853553@nethead.se> <CAESeg0w9u96AiGrvip8yTpaEMZyU93Fpx83-nwe1ysW586o--A@mail.gmail.com>

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

[-- Attachment #1 --]
Script started on Sat Feb 11 13:17:38 2023
$ touch \"f\"o\"o
$ touch \"bar\"
$ touch \"f\ o\ o\"
$ ls
"bar"           "f o o"         "f"o"o          typescript
$ for f in $(find . -type f -name '*"*'); do  mv $f $(echo $f | tr -d '"');
done
mv: rename ./"f to ./f: No such file or directory
mv: rename o to o: No such file or directory
mv: rename o" to o: No such file or directory
$ S="$IFS"
$ IFS="\n"
$ for f in $(find . -type f -name '*"*'); do mv $f $(echo $f | tr -d '"');
done
$ ls
bar             f o o           foo             typescript
$ IFS="$S"
$ exit
Script done on Sat Feb 11 13:21:41 2023

On Sat, Feb 11, 2023 at 1:00 PM Scott Ballantyne <boyvalue@gmail.com> wrote:

>
>
> On Sat, Feb 11, 2023 at 11:43 AM Per olof Ljungmark <peo@nethead.se>
> wrote:
>
>> On 2/11/23 16:43, Scott Ballantyne wrote:
>> >
>> > Remove the first echo command to actually do any changes. Untested.
>> > for f in $(find . -type f -name '*"*'); do echo mv $f $(echo $f | tr -d
>> > '"'); done
>>
>> Produced  "No such file or directory" errors.
>
>
> You must have spaces in the filenames. You can deal with that using IFS.
>
>
>>
>
>>
>>

[-- Attachment #2 --]
<div dir="ltr">Script started on Sat Feb 11 13:17:38 2023<div>$ touch \&quot;f\&quot;o\&quot;o<br>$ touch \&quot;bar\&quot;<br>$ touch \&quot;f\ o\ o\&quot;<br>$ ls<br>&quot;bar&quot;           &quot;f o o&quot;         &quot;f&quot;o&quot;o          typescript</div><div>$ for f in $(find . -type f -name &#39;*&quot;*&#39;); do  mv $f $(echo $f | tr -d &#39;&quot;&#39;); done<br>mv: rename ./&quot;f to ./f: No such file or directory<br>mv: rename o to o: No such file or directory<br>mv: rename o&quot; to o: No such file or directory<br>$ S=&quot;$IFS&quot;<br>$ IFS=&quot;\n&quot;<br>$ for f in $(find . -type f -name &#39;*&quot;*&#39;); do mv $f $(echo $f | tr -d &#39;&quot;&#39;); done<br>$ ls<br>bar             f o o           foo             typescript<br>$ IFS=&quot;$S&quot;</div><div>$ exit<br>Script done on Sat Feb 11 13:21:41 2023<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 11, 2023 at 1:00 PM Scott Ballantyne &lt;<a href="mailto:boyvalue@gmail.com">boyvalue@gmail.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"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 11, 2023 at 11:43 AM Per olof Ljungmark &lt;<a href="mailto:peo@nethead.se" target="_blank">peo@nethead.se</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 2/11/23 16:43, Scott Ballantyne wrote:<br>
&gt; <br>
&gt; Remove the first echo command to actually do any changes. Untested.<br>
&gt; for f in $(find . -type f -name &#39;*&quot;*&#39;); do echo mv $f $(echo $f | tr -d <br>
&gt; &#39;&quot;&#39;); done<br>
<br>
Produced  &quot;No such file or directory&quot; errors.</blockquote><div><br></div><div>You must have spaces in the filenames. You can deal with that using IFS.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
</blockquote></div></div>
</blockquote></div>

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