Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: rename files

by Anonymous Monk
on Aug 08, 2005 at 14:05 UTC ( #481889=note: print w/ replies, xml ) Need Help??


in reply to Re^3: rename files
in thread rename files

by stating the file location i have a new error "Argument "" isn't numeric in addition (+)". with relation to the $number_replace variable? i am running the script from a command line the directory and files are now chmod 777 (wromg i know) and the script is chmod a+x


Comment on Re^4: rename files
Re^5: rename files
by talexb (Canon) on Aug 08, 2005 at 14:09 UTC
      by stating the file location i have a new error "Argument "" isn't numeric in addition (+)". with relation to the $number_replace variable?

    Probably because the file name that's come up is no longer a numeric -- it's x.gif or something.

    You're probably better off using a regexp to skip files that don't have numeric 'name'.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re^5: rename files
by davorg (Chancellor) on Aug 08, 2005 at 14:12 UTC

    Then it looks like you're doing things in the wrong order. It should be something like this:

    my $dir = '/temp_gif'; opendir (DH, $dir) or die "unable $!"; foreach (readdir DH) { my ($number) = split (/\./); print "$number\n"; $number += 338; rename ("$dir/$_", "$dir/$number.GIF") or die $!; }
    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://481889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2015-07-02 01:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (25 votes), past polls