Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum searching for files that have apostrophes
    • Sign In

    • State Verified Answer
    • Replies 12 replies
    • Answers 1 answer
    • Subscribers 66 subscribers
    • Views 1204 views
    • Users 0 members are here

    searching for files that have apostrophes

    Stephen Herrick
    Offline Stephen Herrick over 2 years ago

    All,

    i am exporting documents using 

     Get-PWDocumentsBySearch -FolderPath $RootProject.FullPath -FileName $file -GetVersionsToo | Export-PWDocuments -OutputFolder $CopyTo -Verbose

    i am reading a csv file to get the list of files i need to search and export, the file names are very long and some have special characters as shown below

    2021-07-15_Sub 1497.A_Flatiron-Lane JV, May Creek Bridge Southbound Wave Equation Analysis, PP30'x0.625', APE D50-42 and .pdf

    When i search for the document using ProjectWise search, it finds the document

    however when i run the cmdlet, it errors, stating file not found

    when i expand the variable using the write-host is shows the following

    @{Files_to_Export=2021-07-15_Sub 1497.A_Flatiron-Lane JV, May Creek Bridge Southbound Wave Equation Analysis, PP30'x0.625', APE D50-42 and .pdf}

    but of course when i expand the variable is shows thename im looking for

    PS C:\WINDOWS\system32> $File

    Files_to_Export
    ---------------
    2021-07-15_Sub 1497.A_Flatiron-Lane JV, May Creek Bridge Southbound Wave Equation Analysis, PP30'x0.625', APE D50-42 and .pdf

    what am i doing wrong,

    TIA

    Stephen

    • Sign in to reply
    • Cancel

    Top Replies

    • Brian Flaherty
      Offline Brian Flaherty Thu, Jul 29 2021 11:58 AM in reply to Stephen Herrick +1 verified
      You can try using the Export-PWDocuments with the -UseDMSFolders switch parameter.
    Parents
    • Stephen Herrick
      0 Offline Stephen Herrick Thu, Jul 29 2021 10:17 AM

      also to note, if i set the variable like this $testme = "2021-07-15_Sub 1497.A_Flatiron-Lane JV, May Creek Bridge Southbound Wave Equation Analysis, PP30'x0.625', APE D50-42 and .pdf"

      the search finds the file, 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Jul 29 2021 11:13 AM in reply to Stephen Herrick

      Hey Stephen, I just tested the Get-PWDocumentsBySearch where the document name and/or file name contains apostrophes and everything works as expected.  So, I don't think this is the issue. I think it has to do with the $file variable. Should simply be a string containing the file name only. 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Stephen Herrick
      0 Offline Stephen Herrick Thu, Jul 29 2021 11:32 AM in reply to Stephen Herrick

      OMG...... Problem solved,,,, Forest for the Trees,

      i just now realized, that in my code after reading the csv content

       foreach($File in $FilesToLong)

      i didnt use the header column when i actuarlly ran my search

      BEFORE

      Get-PWDocumentsBySearch -FolderPath $RootProject.FullPath -FileName $File -GetVersionsToo

      AFTER  AND WORKS

      Get-PWDocumentsBySearch -FolderPath $RootProject.FullPath -FileName $File.Files_to_Export -GetVersionsToo

      ARGHHHHH

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Jul 29 2021 11:33 AM in reply to Stephen Herrick

      It happens. Glad  you got it working. Slight smile

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Stephen Herrick
      0 Offline Stephen Herrick Thu, Jul 29 2021 11:36 AM in reply to Brian Flaherty

      One more question,

      the files i am searching for are too long to export file/folder path

      what cmdlet can i use to copy them without the folder structure

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      +1 Offline Brian Flaherty Thu, Jul 29 2021 11:58 AM in reply to Stephen Herrick

      You can try using the Export-PWDocuments with the -UseDMSFolders switch parameter.

      Answer Verified By: Stephen Herrick 

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Reject Answer
      • Cancel
    • Stephen Herrick
      0 Offline Stephen Herrick Thu, Jul 29 2021 12:05 PM in reply to Brian Flaherty

      ahhh,,,, thats the ticket,   thanks,

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject Answer
      • Cancel
    Reply
    • Stephen Herrick
      0 Offline Stephen Herrick Thu, Jul 29 2021 12:05 PM in reply to Brian Flaherty

      ahhh,,,, thats the ticket,   thanks,

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject Answer
      • Cancel
    Children
    No Data

    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