Jump to content

Skipping automatically over access denied files in copying mass files


Recommended Posts

I'm on Windows XP Home

 

I'm trying to backup my entire contents of one folder with many subfolders into another folder, the problem I get is that random files in these files i'm trying to copy over have access denied on them. In other words when I'm doing a copy operation, it breaks the entire operation to give me an error msg saying how 1 file is access denied and cannot be copied to the destination. This stops the whole copy operation, does not clue me where it stopped, and leads me to go digging through all the subfolders to find the location of where it stopped and try to select all the remainder of the files except for this problem 1 to continue the copy operation. If this happens multiple times, you can imagine the anguish.

 

I've tried changing the read only attributes all at once for all the file i would like to copy so I won't run into this error, but some files won't let me change their attributes.

 

All I want to do is copy a giant number of files to another destination, without having to stop the operation every time it encounters a file that cannot be copied. Isn't there a way to do this and simply skip over the ones it doesn't have access to copy?

 

Frustrated...

Thank you

Then you did it wrong. But seeing as you're too lazy to read the manual, to state how what I wrote didn't help you, provide any code, here is a function that will copy a folder. I didn't test it.

 

<?php
function move_folder($folder, $new_location)
{
    $content = scandir($folder);
    if(!is_dir($new_location))
    {
        mkdir($new_location);
    }
    
    foreach($content as $item)
    {
        $old = $folder . DIRECTORY_SEPARATOR . $item;
        if($item == '.' || $item == '..' || !is_readable($old)) continue;
        
        if(is_dir($old))
        {
            move_folder($old, $new_location . DIRECTORY_SEPARATOR . $item);
        }
        else {
            copy($old, $new_location . DIRECTORY_SEPARATOR . $item);
        }
    }
}
?>

I'm not talking about php, I'm talking about copy operations within windows XP, not doing anything with code.

 

Why didn't you just say that instead of saying "it didn't help me" four times within two sentences? You can still use the function though, make a script and run it from the command line. PHP is not just for websites. There is more than one way to do things.

Why dont you try moving the files within command prompt as an administrative? I think you can put an tag there that says ignore errors or something. Try the help! Atleast it should give you an prompt that says which file is denied. Not sure though, worth a try. ( atleast it works in linux ;D )

 

-NikkiLoveGod

In the command prompt

 

xcopy "c:\source" "c:\destination" /C /E /Y

 

That should copy source to destination including all sub directories, continuing past errors, and auto confirming to write over existing files.  Took 30 seconds for google to teach me.

 

http://www.computerhope.com/xcopyhlp.htm

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.