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 \"f\"o\"o<br>$ touch \"bar\"<br>$ touch \"f\ o\ o\"<br>$ ls<br>"bar" "f o o" "f"o"o typescript</div><div>$ for f in $(find . -type f -name '*"*'); do mv $f $(echo $f | tr -d '"'); done<br>mv: rename ./"f to ./f: No such file or directory<br>mv: rename o to o: No such file or directory<br>mv: rename o" to o: No such file or directory<br>$ S="$IFS"<br>$ IFS="\n"<br>$ for f in $(find . -type f -name '*"*'); do mv $f $(echo $f | tr -d '"'); done<br>$ ls<br>bar f o o foo typescript<br>$ IFS="$S"</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 <<a href="mailto:boyvalue@gmail.com">boyvalue@gmail.com</a>> 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 <<a href="mailto:peo@nethead.se" target="_blank">peo@nethead.se</a>> 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> > <br> > Remove the first echo command to actually do any changes. Untested.<br> > for f in $(find . -type f -name '*"*'); do echo mv $f $(echo $f | tr -d <br> > '"'); done<br> <br> Produced "No such file or directory" 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>
