Vault Datastandards 2019 - folder structure - copy files

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ive got the following code i'm trying to get it to copy all the files within my folder structure.
function recursivelyCreateFolders($targetFolder, $sourceFolder)
{
$sourceSubFolders = $vault.DocumentService.GetFoldersByParentId($sourceFolder.Id,$false)
foreach ($folder in $sourceSubFolders) {
$newTargetSubFolder = $vault.DocumentServiceExtensions.AddFolderWithCategory($folder.Name, $targetFolder.Id, $folder.IsLibrary, $folder.Cat.CatId)
$newTargetFiles = $vault.DocumentService.GetLatestFilesByFolderId($folder.Id, $false)
foreach ($file in $newTargetFiles) {
$newTargetPath=$newTargetSubFolder.FullName+"/"+$file.Name
$FileSelectionId = [Autodesk.Connectivity.Explorer.Extensibility.SelectionTypeId]::File
$FileLocation = New-Object Autodesk.Connectivity.Explorer.Extensibility.LocationContext $FileSelectionId, $newTargetPath
$vaultContext.GoToLocation = $FileLocation
}
}
recursivelyCreateFolders -targetFolder $newTargetSubFolder -sourceFolder $folder
}