resolved input-csv random file-names

This topic contains 4 replies, has 3 voices, and was last updated by  David Schmidtberger 3 years, 5 months ago.

  • Author
  • #21877

    David Schmidtberger

    I've been looking and trying to figure out how to use input-csv to grab any csv file within a specified folder.

    need to run a script against csv files that will have different file-names every-time.

    any ideas?

  • #21878

    Dave Wyatt

    You can just use Get-ChildItem *.csv to find the files, and then import them inside a loop. Something like this:

    Get-ChildItem c:\SomeFolder\*.csv |
    ForEach-Object {
        $file = $_
        $data = Import-Csv -Path $file.FullName
        # Do something with the data in $file
  • #21880

    David Schmidtberger

    was hoping for a little easier method, as it will only ever be 1 file in the input file location, i will then move the file out after processing.

    get-childitem seemed a little more complex than needed

  • #21881

    David Schmidtberger

    never mind i should have just tried it. didn't think it actually would be as easy as *.csv

    somedays you over-think things

You must be logged in to reply to this topic.