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

Replies are listed 'Best First'.
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

Re^5: rename files
by talexb (Chancellor) 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