From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Wed, 21 Mar 2012 12:36:08 -0400 To: 9fans@9fans.net Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] removing spaces from filenames Topicbox-Message-UUID: 6cd7e776-ead7-11e9-9d60-3106f5b1d025 > ifs=3D' > ' for (old in `{9 ls *.$EXT}) { i think ls and the temporary file are getting in the=20 way. if you use globbing and execing directly from the shell you can avoid quoting problems. for example, for(old in *^' '^*.$EXT) ifs=3D$nl mv $old `{echo $old | sed 's/ //g'} and now for a digression .... this looks like c programming to me. unfortunately mv doesn't take pairs, so we can't get rid of the for loop, but we can generate parallel lists. i'm going to assume that =E2=98=BA isn't in any of your file names. you could pick something else. the trick here is to paste =E2=98=BA onto the end of every list element. that way we know that '=E2=98=BA ' are end-of-token markers, and other spaces are just spaces. then we can delete the spaces without =E2=98=BAs, then delete the =E2=98=BAs and then turn the remaining spaces (they mark the end of a token) into newlines. i'm going to assume that $ext also contains the '.'. old =3D *^' '^*$ext ifs=3D$nl new =3D `{echo $old^=E2=98=BA | sed 's/([^=E2=98=BA]) /\1/g s/=E2=98=BA//g s/ /\n/g' } (the last two sed steps are combinable; s/=E2=98=BA /\n/g.) now that we have this, we can while(! ~ $#new 0){ mv $old(1) $new(1) old=3D$old(2-) new=3D$new(2-) } this reminds me, the whole ifs thing is awkward because it applies for the whole command which is almost never what you want. i modified rc to allow one to specify a backquote splitter. e.g. new =3D `$nl {echo $old^=E2=98=BA | sed 's/([^=E2=98=BA]) /\1/g s/=E2=98=BA//g s/ /\n/g' } - erik