I'm using the sharepoint powershell cmdlets to upload files to a document library like so:
# Set the variables $WebURL = “http://portal.contoso.com/sites/stuff” $DocLibName = “Docs” $FilePath = “C:\Docs\stuff\Secret Sauce.docx” # Get a variable that points to the folder $Web = Get-SPWeb $WebURL $List = $Web.GetFolder($DocLibName) $Files = $List.Files # Get just the name of the file from the whole path $FileName = $FilePath.Substring($FilePath.LastIndexOf("\")+1) # Load the file into a variable $File= Get-ChildItem $FilePath # Upload it to SharePoint $Files.Add($DocLibName +"/" + $FileName,$File.OpenRead(),$false) $web.Dispose()
Does this method (maybe another class) have a mechanism to check if the file being added is newer than a file of the same name already in the collection? It looks like the method can only overwrite or not overwrite a file of the same name.
Before handling this myself (just comparing modified dates of files being added) I want to be sure there isn't something in the sharepoint API that already takes care of this.