Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: rename files

by talexb (Canon)
on Aug 08, 2005 at 13:59 UTC ( #481885=note: print w/ replies, xml ) Need Help??


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

OK, now we're getting somewhere. Is it unable to find the source file, the first file? I expect that's the case, since you're trying to create the destination file.

Are you checking that the file exists as the same user? That is, are you running the script from a prompt or is it a CGI or something run from cron?

The reason I'm asking is that the script is not able to see the file, while you are. The script isn't lying -- it really can't see the file. If you can see the file, then you must be looking at a different system or running with different privileges.

Alex / talexb / Toronto

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


Comment on Re^3: rename files
Download Code
Re^4: rename files
by Anonymous Monk on Aug 08, 2005 at 14:05 UTC
    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
        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

      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://481885]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-08-22 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (153 votes), past polls