Author Posts

January 15, 2015 at 5:22 am

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?

January 15, 2015 at 5:27 am

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
}

January 15, 2015 at 5:30 am

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

January 15, 2015 at 5:32 am

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

somedays you over-think things