[Watford] Bulk Rename Files
Dimitrios Siganos
dimitris at siganos.org
Wed Dec 5 09:20:13 UTC 2012
Hi Rob,
You are mixing/confusing glob patterns and regular expressions.
A question mark (?) represents a mandatory single character in a glob
pattern.
A question mark in a regular expression means something entirely
different. In a regular expression a mandatory single character is
represented by a dot (.). The utility 'rename' expects regular expressions.
This is probably want you want:
ls -1 *.gsm | rename -v "s/^OUT...-........-......-//g"
Regards,
Dimitris
On 05/12/12 09:09, Rob Jefferis wrote:
> Actually, i lie. I was running find -iname '*' -exec rename -v
> "s/^OUT???-????????-??????-//g" *.gsm '{}' \;
>
> stripping the *.gsm as in your suggestion does indeed get rid of the too
> many arguments, but also doesn't seem to rename the files. I will
> continue testing.
>
> Thanks
>
> Rob
>
> ------------------------------------------------------------------------
> *From:* watford-bounces at mailman.lug.org.uk
> [watford-bounces at mailman.lug.org.uk] on behalf of Rob Jefferis
> [rob at letchmore.co.uk]
> *Sent:* 05 December 2012 08:58
> *To:* watford at mailman.lug.org.uk
> *Subject:* Re: [Watford] Bulk Rename Files
>
> Thanks Steve, that is pretty much what I have been trying but for some
> reason I still get the error argument list too long. hmmmmm
>
> Thanks
>
> Rob
>
> ------------------------------------------------------------------------
> *From:* watford-bounces at mailman.lug.org.uk
> [watford-bounces at mailman.lug.org.uk] on behalf of Steve Horsley
> [steve.horsley at gmail.com]
> *Sent:* 05 December 2012 08:46
> *To:* watford at mailman.lug.org.uk
> *Subject:* Re: [Watford] Bulk Rename Files
>
> Something like this might work:
> find -iname 'out*' -exec rename -v "s/^OUT???-????????-??????-//g" '{}' \;
>
> Perehaps a bit slow, but since you've been trying for quite some time, I
> guess that won't matter too much.
>
> Steve
>
> On 5 December 2012 08:36, Rob Jefferis <rob at letchmore.co.uk
> <mailto:rob at letchmore.co.uk>> wrote:
>
> Morning all, apologies for the delay in getting back on this.
>
> Thanks very much for the replies.
>
> I managed to find a line that worked to rename the files as I wanted
> which is, rename -v "s/^OUT???-????????-??????-//g" *.gsm
>
> The problem i have now is that running that on the actual folder
> gives me an Argument list too long error.
>
> When i copy files between these folders i use the line find -iname
> * -exec cp -v {} /temp/. \; so that i am essentially copying one
> file at a time.
>
> I have been trying to combine my 2 examples to complete my bulk
> rename but so far without much success. Any help would be appreciated.
>
> Thanks again
>
> Rob
>
>
>
> ________________________________________
> From: watford-bounces at mailman.lug.org.uk
> <mailto:watford-bounces at mailman.lug.org.uk>
> [watford-bounces at mailman.lug.org.uk
> <mailto:watford-bounces at mailman.lug.org.uk>] on behalf of Alain
> Williams [addw at phcomp.co.uk <mailto:addw at phcomp.co.uk>]
> Sent: 28 November 2012 00:44
> To: watford at mailman.lug.org.uk <mailto:watford at mailman.lug.org.uk>
> Subject: Re: [Watford] Bulk Rename Files
>
>
> On Tue, Nov 27, 2012 at 11:43:05PM +0000, Rob Jefferis wrote:
> > Hi guys, I have a load of files in a directory with file names
> similar to below
> >
> > OUT119-20120702-084956-1341215396.177198.gsm
> >
> > It is basically OUT(dialingextensionnumber)-DATE-TIME-UNIQUEID.gsm
> >
> > I would like to somehow bulk rename all the files in this folder
> to strip everything other than the uniqueid.gsm bit
> >
> > So in this case I want the file to end up called
> >
> > 1341215396.177198.gsm
> >
> >
> > Is there a quick way to do this?
>
> Using ksh
>
> for file in *.gsm
> do mv $file ${file#~(E:+(OUT+(\d)-+(\d)-+(\d)-))}
> done
>
> The syntax is a little strange.
>
> --
> Alain Williams
> Linux/GNU Consultant - Mail systems, Web sites, Networking,
> Programmer, IT Lecturer.
> +44 (0) 787 668 0256 <tel:%2B44%20%280%29%20787%20668%200256>
> http://www.phcomp.co.uk/
> Parliament Hill Computers Ltd. Registration Information:
> http://www.phcomp.co.uk/contact.php
> #include <std_disclaimer.h>
>
> _______________________________________________
> Watford mailing list
> Watford at mailman.lug.org.uk <mailto:Watford at mailman.lug.org.uk>
> https://mailman.lug.org.uk/mailman/listinfo/watford
>
>
> _______________________________________________
> Watford mailing list
> Watford at mailman.lug.org.uk <mailto:Watford at mailman.lug.org.uk>
> https://mailman.lug.org.uk/mailman/listinfo/watford
>
>
>
>
> _______________________________________________
> Watford mailing list
> Watford at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/watford
>
More information about the Watford
mailing list