none
Search for Multiple files listed in a CSV (not exact match) - Return a matched files and file location(s) RRS feed

  • Question

  • I'm new to Powershell and I would like help creating a powershell script.

    I have a list of part numbers (50,000) in .csv format.

    From a root folder, I want to find all files that have the part number in it's file Name (ABC12345677*), I want to write the file Location(s) either back to the .csv or into another file.

    Any help with this would be kindly appreciated.

    • Moved by Bill_Stewart Friday, March 9, 2018 7:44 PM This is not "scripts on demand"
    Monday, January 8, 2018 9:48 AM

All replies

  • What have you tried so far?

    I'll be happy to help you with your code, however not so much with writing it from scratch for you; no offense meant.

    Monday, January 8, 2018 9:56 AM
  • So welcome to The Official Scripting Guys Forum.

    You might read this first please: This forum is for scripting questions rather than script requests.

    Also find scripts here: PowerShell Gallery or here: TechNet Gallery - resources for IT professionals.

    Learn PowerShell: Microsoft Virtual Academy - Getting Started with Microsoft PowerShell.

    Script requests: Microsoft Technet Script Center - Requests.

    Good luck and Have a lot of fun!


    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Monday, January 8, 2018 12:35 PM
  • $A=Get-ChildItemI:RootFolder\-recurse



    Import-Csv

    .\Rootfolder\Parts.csv|ForEach-Object{



    $A

    -match"$($_.PartNumber).*"|%{ $_.FullName } |echo>>".\RootFolder\FilePaths.csv"


    }

    Monday, January 8, 2018 2:38 PM
  • Your code is incomplete or broken. Please do not post colored code. It's almost unreadable. Use the code posting tool of the post editor instead.

    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Monday, January 8, 2018 3:24 PM
  • $A = Get-ChildItem RootFolder\ -recurse 
    
    Import-Csv .\Rootfolder\Partlist.csv | ForEach-Object {
    
    $A -match "$($_.Partnumber).*" | Select-Object -Property Name, FullName | Export-Csv -Append  -Path ".\RootFolder\Paths.csv" -Delimiter ";"
    
    }
    
    

    This is working. It will search the Root Folder for any matches to the the part numbers in "Partlist.csv" it Outputs the full Path and Part number to a seperate csv. It works on partical match and return multiple search results as required. I think I have successfully written my first working ppowershell script. If you have any suggestions or improvements please let me know.
    • Proposed as answer by TobyU Tuesday, January 9, 2018 9:14 AM
    Tuesday, January 9, 2018 7:59 AM
  • This is working.

    Great. I'm proud of you.  ;-)

    If it does the job and you're satisfied with the result, don't change it - take the next challange! ;-)


    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Tuesday, January 9, 2018 9:12 AM