[Watford] Bulk Rename Files

Rob Jefferis rob at letchmore.co.uk
Wed Dec 5 08:56:05 UTC 2012


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/watford/attachments/20121205/fc958ee9/attachment.html>


More information about the Watford mailing list