I recently encountered an issue when exporting documents out of a ProjectWise datasource and importing them into another datasource. The issue encountered had to do with the long path names. ProjectWise doesn’t care how long the path is to a folder or document. However, Windows does. There is a hard limit of 260 characters.
The following is one way to work around this limitation. The process was broken down into two steps.
First: Export the ProjectWise documents to the local drive without recreating the folder path and create an Excel spreadsheet to capture the full folder path, name, etc.
Second: Import the ProjectWise documents into the secondary ProjectWise datasource using the information within the Excel spreadsheet to recreate the folder structure.
Exporting documents from ProjectWise:
# Parameters [string] $PWFolder = 'Projects\BSI200 - Peterborough Geospatial Investigation Parent', [string] $ExportFolder = 'D:\Temp\testExport', [string] $OutputFile = "$ExportFolder\Output.xlsx" $docs = Get-PWDocumentsBySearch -FolderPath $PWFolder -GetAttributes -Verbose #Create datatable $dt = New-Object System.Data.DataTable ('ExportDocs') $Columns = 'DocName', 'DocDesc', 'FullPath', 'ProjectID', 'ExportFolder' foreach ($Column in $Columns){ $dt.Columns.Add($Column) } foreach ($doc in $docs) { # Create new datarow $dr = $dt.NewRow() $dr['DocName'] = $doc.Name $dr['DocDesc'] = $doc.Description $dr['FullPath'] = $doc.FullPath.Substring(0, $doc.FullPath.LastIndexOf('\')) $dr['ProjectID'] = $doc.ProjectID $dr['ExportFolder'] = $ExportFolder # Add datarow to datatable $dt.Rows.Add($dr) CheckOut-PWDocuments -InputDocument $doc -CopyOut -ExportFolder $ExportFolder -NoReferences -Verbose } New-XLSXWorkbook -InputTables $dt -OutputFileName $OutputFile -Open -Verbose
Importing documents into ProjectWise:
# Parameters [string] $ImportFolder = 'D:\Temp\testExport', [string] $ImportFile = "$ImportFolder\Output.xlsx" # Import document information from spreadsheet created on export. $FromXLS = Get-TablesFromXLSXWorkbook -InputFileName $ImportFile -Verbose foreach ($item in $FromXLS.Rows) { try { Get-PWFolders -FolderPath $item.FullPath -JustOne -ErrorAction Stop } catch { New-PWFolder -FolderPath $item.FullPath -Verbose } # end try/catch try{ Get-PWDocumentsBySearch -FolderPath $item.FullPath -DocumentName $item.DocName -JustThisFolder -Verbose -ErrorAction Stop Write-Warning -Message ("Document '{0}' already exists in folder {1}" -f $item.DocName, $item.FullPath) } catch { New-PWDocument -FolderPath $item.FullPath -FilePath "$($item.ExportFolder)\$($item.DocName)" -Description $item.DocDesc -Verbose } # try/catch } # end foreach($item...
Example Output to Excel Spreadsheet:
DocName : BSI200 – Peterborough Geospatial Investigation.pdf
DocDesc : Concat2.pdf
FullPath : Projects\BSI200 – Peterborough Geospatial Investigation
Parent\BSI200 – Peterborough Geospatial Investigation SubFolder
1\BSI200 – Peterborough Geospatial Investigation SubFolder 2
ProjectID : 3557
ExportFolder : D:\Temp\testExport
DocName : BSI200 – Peterborough Geospatial Investigation 3.pdf
DocDesc : Concat2.pdf
FullPath : Projects\BSI200 – Peterborough Geospatial Investigation
Parent\BSI200 – Peterborough Geospatial Investigation SubFolder
1\BSI200 – Peterborough Geospatial Investigation SubFolder 2\BSI200
– Peterborough Geospatial Investigation SubFolder 3
ProjectID : 3558
ExportFolder : D:\Temp\testExport