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
--000000000000c8d7ff05f47109c8 Content-Type: text/plain; charset="UTF-8" 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. > > >> > >> >> --000000000000c8d7ff05f47109c8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Script started on Sat Feb 11 13:17:38 2023<div>$ touch \&q= uot;f\"o\"o<br>$ touch \"bar\"<br>$ touch \"f\ o\ = o\"<br>$ ls<br>"bar" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quo= t;f o o" =C2=A0 =C2=A0 =C2=A0 =C2=A0 "f"o"o =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0typescript</div><div>$ for f in $(find . -type f -n= ame '*"*'); do =C2=A0mv $f $(echo $f | tr -d '"')= ; done<br>mv: rename ./"f to ./f: No such file or directory<br>mv: ren= ame o to o: No such file or directory<br>mv: rename o" to o: No such f= ile or directory<br>$ S=3D"$IFS"<br>$ IFS=3D"\n"<br>$ f= or f in $(find . -type f -name '*"*'); do mv $f $(echo $f | tr= -d '"'); done<br>$ ls<br>bar =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 f o o =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 foo =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 typescript<br>$ IFS=3D"$S"</div><div>$ e= xit<br>Script done on Sat Feb 11 13:21:41 2023<br></div></div><br><div clas= s=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, Feb 11, 202= 3 at 1:00 PM Scott Ballantyne <<a href=3D"mailto:boyvalue@gmail.com">boy= value@gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" s= tyle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pad= ding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir= =3D"ltr"><br></div></div></div><br><div class=3D"gmail_quote"><div dir=3D"l= tr" class=3D"gmail_attr">On Sat, Feb 11, 2023 at 11:43 AM Per olof Ljungmar= k <<a href=3D"mailto:peo@nethead.se" target=3D"_blank">peo@nethead.se</a= >> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"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> > <br> > Remove the first echo command to actually do any changes. Untested.<br= > > for f in $(find . -type f -name '*"*'); do echo mv $f $(e= cho $f | tr -d <br> > '"'); done<br> <br> Produced=C2=A0 "No such file or directory" errors.</blockquote><d= iv><br></div><div>You must have spaces in the filenames. You can deal with = that using IFS.</div><div><br></div><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex">=C2=A0<br></blockquote><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex"><br> <br> </blockquote></div></div> </blockquote></div> --000000000000c8d7ff05f47109c8--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAESeg0z1ygZQkLZoPhYcSchnrvKJf0zLh7P_89gDDcw3MDBdEA>