RE: renaming files



Hello.
Instead of `mv..` system call,you could use perl's inner function 'rename()' to do the things you wanted.
Also use 'File::Find' to do the searching for files.


From: Adriano Allora <all.adr@xxxxxxxxxxxx>
To: beginners@xxxxxxxx
Subject: renaming files
Date: Fri, 30 Jun 2006 16:48:09 +0200

hi to all,

does exists a way to rename automatically files?

I mean: I've got directories with this content:

EN0.tmp
EN1.tmp
EN2.tmp
EN3.tmp
EN4.tmp
...
IT0.tmp
IT1.tmp
IT2.tmp
IT3.tmp
IT4.tmp
...

Now, some couples of files were deleted (you can imagine the EN1.tmp/IT1.tmp) but I need no holes in my list.

Is there something less rude (and more general) than

$c = 0;
while(<>)
{
if($ARGV=~/^([A-Z]+)(\d+)\.tmp/)
{
$nuname = $1.$c.'.tmp';
`mv $ARGV $nuname';
$c++;
}
}

Thanks at all,

alladr

|^|_|^|_|^| |^|_|^|_|^|
| | | |
| | | |
| |*\_/*\_/*\_/*\_/*\_/* | |
| |
| |
| |
| http://www.e-allora.net |
| |
| |
**************************************


--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>




.



Relevant Pages

  • Re: dpkg: error processing /var/cache/apt/archives/linux-image-2.6.18-5-486_2.6.18.d
    ... dpkg: error processing ... Searching for GRUB installation directory ... ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ...
    (Debian-User)
  • Re: Epson EPL-6100L
    ... On 12/28/08 14:48, Koh Choon Lin wrote: ... My box is using, or rather, unable to use an USB printer Epson ... Searching for the driver led me to the epsonepl Project. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ...
    (Debian-User)
  • Re: distributions: UBUNTU vs DEBIAN
    ... I was referring to my only other post to this thread, ... Okay, after some searching I found it (at: ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: distributions: UBUNTU vs DEBIAN
    ... after some searching I found it (at: ... for the interested) and I'm afraid I cannot comment too much on it. ... when they speak to you for your own good it's interference. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: newbie question
    ... "google" for a while before you ask. ... you can learn a lot while searching ... and it turns out that it sure looks like the messages I'm trying to capture are generated too early in the startup process to hit the log files - guess I have to connect my laptop to the serial port and capture the console traffic ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ...
    (Debian-User)