in reply to Mass file renaming

There’s not much to guess the problem from in your post.

First, I’m not sure about the privilege system on Windows, but in Unix, renaming requires write permissions on the directory, not the file, so you may want to check that. However, I don’t believe that’ll turn out to have been the problem.

Second, do you have some actual examples of $oldname and $newname values from the rename that fails? Without those, it’s going to be very difficult to guess at your problem.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: Mass file renaming
by Anonymous Monk on Nov 07, 2005 at 15:25 UTC
    The data sample is currently stored on my C:/temp local drive. Admin, User, Everyone, System permissions are all Full Control.

    I have chdir to C:/Temp/Storage and verified by cwd.

    $oldfile name is typically location.csv ie "Langden Brook.csv"

    $newfile name is typically 573796RSst.csv

    What I find difficult to get my head around is that I can rename a file in the same dir so long as the filextension is not the one referenced in the foreach(@files) where the filehandle is say all csv files in the dir.

    Thanks again.

      You didn’t answer my question. I didn’t want to know what you think is in the variables; that’s just programming by coincidence. 99% of the bugs I encounter are due to variables containing things are than what I expected they would. Put an actual warn "$newfile $oldfile" if not $success; or some such in your code and make sure you know what the variables contain.

      Makeshifts last the longest.

        Hi

        You're right, I didn't, but I already have the following code which does what you say, so I do know that the vars going in to the rename are good:

        print qq{Attempting to rename $oldname to $newname\n};

        $success=rename $oldname, $newname;

        if ($success){print "Changed $oldname to $newname\n"}

        else {print "Failed to rename $oldname to $newname $!\n";exit};

        so I do actually know what's in there and its right enough - eg renaming Greenberfield.csv to 573427RSSt.csv

        Thanks again.