From Mature Gibbon, 3 Years ago, written in PowerShell.
Embed
  1. ### Configuration
  2. # CSVs location
  3. $location = "C:\temp\mestacsv\"
  4.  
  5. # how many rows per CSV?
  6. $rowsMax = 50
  7.  
  8. # Get all CSV under current folder
  9. $allCSVs = Get-ChildItem $location\* -include *.csv
  10.  
  11. # Read and split all of them
  12. $allCSVs | ForEach-Object {
  13.     Write-Host $_.Name;
  14.     $content = Import-Csv $_.FullName -Delimiter ";"
  15.     $insertLocation = ($_.Name.Length - 4)
  16.     for($i=1; $i -le $content.length ;$i+=$rowsMax){
  17.     $newName = $_.Name.Insert($insertLocation, "splitted_"+$i)
  18.     $content|select -first $i|select -last $rowsMax | convertto-csv -NoTypeInformation | % { $_ -replace '"', ""} | out-file $location\$newName -fo -en ascii
  19.     }
  20. }