0

I have 100s of Document Libraries with documents in them. The path is: CustomerNumbers/Lists/Documents, I would like to move them 1 folder out; to CustomerNumbers/Documents.

All metadata must be retained.

Can I do this with PowerShell ? Any resources on the web that can help me to?

3
  • yes you can do this on powershell but you need have the permission Commented Mar 21, 2014 at 15:12
  • thanks, have you done this before or know someone who has? Do I simply copy them to the desired destination or is it a simple command to "move" the files.
    – williamwmy
    Commented Mar 21, 2014 at 15:20
  • Copy from one folder to the other folder. BTW you will lose all your versions. Do u need code? Commented Mar 21, 2014 at 15:27

1 Answer 1

2

So you have two ways to do that:

First : The easiest: Navigate to the source document library and open the "explorer view" then copy the documents and move those to the new path

Second: Type a script or program

$src       = $web.Lists [ "source" ]
$dest      = $web.Lists [ "dest" ]
$destFiles = $dest.Folders [ "mydoc" ]
foreach ( $item in $srcLibrary.Items )
{ 
   if ( $item.File )
   {
        $file = $item.file.OpenBinary()
        $destURL = $destFiles.Folder.Url + "/" + $item.file.Name 
        $destFiles.Add ( $destURL, $file, $true )
    }
}

BTW You will lost all your versions if the version option was enabled

1
  • @lwbecker2 I still waiting a integration between stackexchange and gits :) Commented Mar 24, 2014 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.