### Configuration # CSVs location $location = "C:\temp\mestacsv\" # how many rows per CSV? $rowsMax = 50 # Get all CSV under current folder $allCSVs = Get-ChildItem $location\* -include *.csv # Read and split all of them $allCSVs | ForEach-Object { Write-Host $_.Name; for($i=1; $i -le $content.length ;$i+=$rowsMax){ $content|select -first $i|select -last $rowsMax | convertto-csv -NoTypeInformation | % { $_ -replace '"', ""} | out-file $location\$newName -fo -en ascii } }