Skip to main content
Files were corrupt before I moved them
Source Link
user13186
  • 886
  • 1
  • 16
  • 34

I am trying to move files from the RootFolder to a subfolder via PowerShell (would like to keep SPItem.Id from changing if possible). The code I have used is pretty straight forward. starting to think the file is moving but the item isn't, causing them both to corrupt & go missing. Still not sure.

$web = get-spweb http://mySPweb.com
$list = $web.Lists["MyDocuments"]
$DestUrl ="/MyDocuments/SubFolderName/myfile.docx"
$file = $web.GetFile("/MyDocuments/myfile.docx")
$file.moveTo($DestUrl,$true)
$file.update()

I get no errors, the file object still exists. But checking via UI the folder is still empty

Late update:

The process used by the administrators to restore the DB for testing, corrupted the files. The above code works.

I am trying to move files from the RootFolder to a subfolder via PowerShell (would like to keep SPItem.Id from changing if possible). The code I have used is pretty straight forward. starting to think the file is moving but the item isn't, causing them both to corrupt & go missing. Still not sure.

$web = get-spweb http://mySPweb.com
$list = $web.Lists["MyDocuments"]
$DestUrl ="/MyDocuments/SubFolderName/myfile.docx"
$file = $web.GetFile("/MyDocuments/myfile.docx")
$file.moveTo($DestUrl,$true)
$file.update()

I get no errors, the file object still exists. But checking via UI the folder is still empty

I am trying to move files from the RootFolder to a subfolder via PowerShell (would like to keep SPItem.Id from changing if possible). The code I have used is pretty straight forward. starting to think the file is moving but the item isn't, causing them both to corrupt & go missing. Still not sure.

$web = get-spweb http://mySPweb.com
$list = $web.Lists["MyDocuments"]
$DestUrl ="/MyDocuments/SubFolderName/myfile.docx"
$file = $web.GetFile("/MyDocuments/myfile.docx")
$file.moveTo($DestUrl,$true)
$file.update()

I get no errors, the file object still exists. But checking via UI the folder is still empty

Late update:

The process used by the administrators to restore the DB for testing, corrupted the files. The above code works.

Source Link
user13186
  • 886
  • 1
  • 16
  • 34

File gone after using SPFile.MoveTo

I am trying to move files from the RootFolder to a subfolder via PowerShell (would like to keep SPItem.Id from changing if possible). The code I have used is pretty straight forward. starting to think the file is moving but the item isn't, causing them both to corrupt & go missing. Still not sure.

$web = get-spweb http://mySPweb.com
$list = $web.Lists["MyDocuments"]
$DestUrl ="/MyDocuments/SubFolderName/myfile.docx"
$file = $web.GetFile("/MyDocuments/myfile.docx")
$file.moveTo($DestUrl,$true)
$file.update()

I get no errors, the file object still exists. But checking via UI the folder is still empty