Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Is there a cmdlet to search, and rename folders,
    • Sign In

    • State Verified Answer
    • Replies 6 replies
    • Answers 1 answer
    • Subscribers 67 subscribers
    • Views 3261 views
    • Users 0 members are here

    Is there a cmdlet to search, and rename folders,

    Stephen Herrick
    Offline Stephen Herrick over 4 years ago

    I need to rename folders, after project has changed requirements, i.e. substitute part of the folder name, 6701 Piping --> 6740 Piping

    TIA

    Stephen,

    • Sign in to reply
    • Cancel
    • Dan Williams
      0 Offline Dan Williams Tue, Apr 23 2019 3:10 PM

      Stephen,

      You could use Get-PWFolders or something similar to get your list of folders and Update-PWFolderNameProps to change the folders' names.

      No doubt there's more than one way to do what you ask.  Perhaps Update-PWRichProjectsFromSpreadsheet might be of use to you.

      Answer Verified By: Stephen Herrick 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Reject Answer
      • Cancel
    • Stephen Herrick
      0 Offline Stephen Herrick Tue, Apr 23 2019 3:13 PM in reply to Dan Williams

      Thanks Dan, I took some time and actually thought about this, and saw what I needed to do.. 

      $checkprints = Get-PWFolders -FolderName '6701'

      Write-Host $checkprints.Count

      foreach ($folder in $checkprints){

      Write-Host "Updating oldr name $($Folder.oldpath)"

      Update-PWFolderNameProps -NewName "PPL-Pipelines" -FolderPath $folder.FullPath

      }

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject Answer
      • Cancel
    • Kevin van Haaren
      0 Offline Kevin van Haaren Tue, Apr 23 2019 4:07 PM in reply to Stephen Herrick

      I like using FolderID for the identifier in Update-PWFolderNameProps as it's more exact, don't have to worry about duplicates.

      Also, did you find your Get-PWFolders -FolderName '6701' worked? It only works for me if that is the exact full name of the folder. If i had a folder named '6701 Piping' it wouldn't find it.

      Super slow but I had to use:

      $checkprints = Get-PWFolders -FolderPath "path\to\projectroot" | where name -like '6701*'

      my script ended up looking like:

      $checkprints = Get-PWFolders -FolderPath 'path\to\projet' | where Name -like '6701*'
      Write-Host $checkprints.Count
      
      foreach ($folder in $checkprints) {
          Write-Host "Updating oldr name $($Folder.oldpath)"
          Update-PWFolderNameProps -NewName $folder.name.replace('6701','6740') -FolderID $folder.id
      }
      

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Stephen Herrick
      0 Offline Stephen Herrick Tue, Apr 23 2019 6:01 PM in reply to Kevin van Haaren

      Hi Kevin,

      I ended up using the following, wasn't too bad for speed, I thought it went fast

      $RootFolder = (Show-PWFolderBrowserDialog).ProjectID

      $SearchFolders = Get-PWFolders -FolderID $RootFolder | Where Name -like '*6701*'

       

       

      foreach ($Folder in $SearchFolders)

      {

      Write-Host "Updating oldr name $($Folder.Name)"

      Update-PWFolderNameProps -NewName $Folder.Name.replace('6701','6740') -FolderID $Folder.ProjectID

      }

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Kevin van Haaren
      0 Offline Kevin van Haaren Tue, Apr 23 2019 6:22 PM in reply to Stephen Herrick

      oh, i like calling the browser dialog to select the folder. nice.  speed of get-pwfolders is going to be dependent on the total number of sub-folders. If someone takes your script and runs it against a giant folder tree it'll be slow.

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    >

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies