🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #746

Re: Renombrar ficheros

#746
From: Pascal Bourguignon
Date: Mon, 25 Sep 2006 17:55
30 lines
2048 bytes
ravenheart <ravenheart.j@gmail.com> writes:

>> Soy nuevo en esto del scripting.
>> Tengo una serie de ficheros en un directorio con la misma extensi�n
>> (01.xxx, 02.xxx, ...) y quiero renombrarlos a (01.yyy, 02.yyy, ...)
>> �Como hacrlo?
>> Gracias
>
> O, en su defecto, me valdr�a con quitarles (los n �ltimos caracteres)

n=4 # por ejemplo
for f in ??.* ; do 
   g="$(echo "$f"|sed -e "s/^\([0-9][0-9]\..*\).\{$n\}/\1/")"
   [ "$f != "$g" ] && mv "$f" "$g"
done


Total, leer:

man bash
man sed
man 7 regexp
man mv
man test

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"This machine is a piece of GAGH!  I need dual Opteron 850
processors if I am to do battle with this code!"
Technical Details
Message-ID: <873baf25mr.fsf@thalassa.informatimago.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.google.com!news.germany.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <ef93cn$pf2$1@hefestos.uned.es> <ef944m$pf2$2@hefestos.uned.es>

Show Full Headers
Complete Article Headers
X-Google-Thread: f86c8,49b05d3cf6e2b1ae
X-Google-Attributes: gidf86c8,public
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.google.com!news.germany.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Pascal Bourguignon <pjb@informatimago.com>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Renombrar ficheros
Date: Mon, 25 Sep 2006 19:55:08 +0200
Organization: Informatimago
Lines: 30
Message-ID: <873baf25mr.fsf@thalassa.informatimago.com>
References: <ef93cn$pf2$1@hefestos.uned.es> <ef944m$pf2$2@hefestos.uned.es>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: individual.net eG4DZtX5Uxb+76EccSqs1gzq+Bd4XTZd3XR0NLLH78M7B8NfiP
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA
      oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9
      033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac
      l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR
      mV+hO/VvFAAAAABJRU5ErkJggg==
X-Accept-Language:         fr, es, en
X-Disabled: X-No-Archive: no
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)
Cancel-Lock: sha1:C3U3fxVLhB5kLCyRwwEMmdO/dyo=