Date: Tue, 16 Dec 2014 20:39:07 +0100 From: Polytropon <freebsd@edvax.de> To: jungle Boogie <jungleboogie0@gmail.com> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>, kpneal@pobox.com Subject: Re: Perl rename utility assistance Message-ID: <20141216203907.6dddfe9e.freebsd@edvax.de> In-Reply-To: <CAKE2PDsB6KC1iNHcp4Tq0HHiavJpvQYqh6-GVHq9vF2thhBvVA@mail.gmail.com> References: <54907B51.1060807@gmail.com> <20141216184002.GA26978@neutralgood.org> <CAKE2PDsB6KC1iNHcp4Tq0HHiavJpvQYqh6-GVHq9vF2thhBvVA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 16 Dec 2014 11:20:50 -0800, jungle Boogie wrote: > Hello Kevin, > On 16 December 2014 at 10:40, <kpneal@pobox.com> wrote: > > A little bit of quick scripting should do this without needing a > > rename or whatever program. > > > > #! /bin/sh > > > > oname="$1" > > nname=$(echo "$oname" | sed 's/_/ /') > > > > set -x > > mv "$oname" "$nname" > > What if you have a directory full of files you want to update? See: #!/bin/sh set -x for oname in *.*; do nname=`echo "${oname}" | sed 's/_/ /'` mv "${oname]" "${nname}" done Not that it is _wrong_ to deal with file name iteration that way. Take my example as "works in many cases, but you shouldn't do it that way". Instead, go ahead and read: http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html http://www.dwheeler.com/essays/filenames-in-shell.html Then return to do it better. ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141216203907.6dddfe9e.freebsd>