[Watford] Bulk Rename Files
Rob Jefferis
rob at letchmore.co.uk
Wed Dec 5 08:33:41 UTC 2012
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 [watford-bounces at mailman.lug.org.uk] on behalf of Alain Williams [addw at phcomp.co.uk]
Sent: 28 November 2012 00:44
To: 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 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
https://mailman.lug.org.uk/mailman/listinfo/watford
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/watford/attachments/20121205/0ff5578c/attachment.html>
More information about the Watford
mailing list